[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

two Date classes?

Mark Volkmann

7/10/2006 2:32:00 PM

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?

--
R. Mark Volkmann
Object Computing, Inc.

4 Answers

Tim Pease

7/10/2006 6:00:00 PM

0

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
<snip>

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

Blessings,
Tim Pease

On 7/10/06, Mark Volkmann <r.mark.volkmann@gmail.com> wrote:
> 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?
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>
>

Logan Capaldo

7/10/2006 8:14:00 PM

0


On Jul 10, 2006, at 10:31 AM, Mark Volkmann wrote:

> 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?
>

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.


> --
> R. Mark Volkmann
> Object Computing, Inc.
>


Mark Volkmann

7/10/2006 9:48:00 PM

0

On 7/10/06, Tim Pease <tim.pease@gmail.com> 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]

> $ 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
> <snip>
>
> 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'">

> Blessings,
> Tim Pease
>
> On 7/10/06, Mark Volkmann <r.mark.volkmann@gmail.com> wrote:
> > 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?

--
R. Mark Volkmann
Object Computing, Inc.

Mark Volkmann

7/10/2006 9:50:00 PM

0

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

On 7/10/06, Mark Volkmann <r.mark.volkmann@gmail.com> wrote:
> On 7/10/06, Tim Pease <tim.pease@gmail.com> 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]
>
> > $ 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
> > <snip>
> >
> > 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'">
>
> > Blessings,
> > Tim Pease
> >
> > On 7/10/06, Mark Volkmann <r.mark.volkmann@gmail.com> wrote:
> > > 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?
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>


--
R. Mark Volkmann
Object Computing, Inc.