Two Date classes?

It seems that there is a Date class in the core library and the
standard library. Is this correct? The following code


core = Date.methods.sort

require ‘date’
std = Date.methods.sort

puts “methods in std Date that aren’t in core Date”
puts std - core


outputs lots of method names.

Pickaxe doesn’t document a Date class in the core libraries.
Does anybody know why there are two classes named Date in the standard
Ruby distribution?

Simple exercise on my machine …

$ ruby -v
ruby 1.8.4 (2005-12-24) [powerpc-linux]

$ ruby -e ‘puts Date.methods(false).sort’
-e:1: uninitialized constant Date (NameError)

$ ruby -r date -e ‘Date.methods(false).sort’
_load
_parse
_strptime
ajd_to_amjd
ajd_to_jd
amjd_to_ajd

What version of ruby are you running?
Might you have included Date in an .irbrc file or some other piece of
code?

Blessings,
Tim P.

On Jul 10, 2006, at 10:31 AM, Mark V. wrote:

puts “methods in std Date that aren’t in core Date”
puts std - core


outputs lots of method names.

Pickaxe doesn’t document a Date class in the core libraries.
Does anybody know why there are two classes named Date in the standard
Ruby distribution?

There aren’t. If you have rubygems in your RUBYOPT (or similiar) it
pulls in time.rb which adds some methods to the Date class (and
changes it’s behavior slightly). This could be what you are seeing.

On 7/10/06, Tim P. [email protected] wrote:

Simple exercise on my machine …

$ ruby -v
ruby 1.8.4 (2005-12-24) [powerpc-linux]

I’m running
ruby 1.8.4 (2005-12-24) [i386-mswin32]

What version of ruby are you running?
Might you have included Date in an .irbrc file or some other piece of code?

I have the RUBYOPT environment variable set to rubygems. Quite
possible that does a require on the Date class. However, even if it
does, why do I get extra methods after I do a “require ‘date’”>

Ignore my last reply. Logan answered my question. Thanks!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs