[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Date and DateTime on the Mac

Ronald Otto Valentin

8/20/2007 7:46:00 PM

I have installed ruby for Mac OS/X. Strangely, the classes Date and
DateTime
are not known:

NameError: uninitialized constant DateTime
from (irb):1

At least some other classes (I tried File and Time) exist, so it is
not that the
installation were completely broken.

What could be the problem here?

Ronald

4 Answers

Gary Wright

8/20/2007 7:58:00 PM

0


On Aug 20, 2007, at 3:50 PM, Ronny wrote:

> I have installed ruby for Mac OS/X. Strangely, the classes Date and
> DateTime
> are not known:
>
> NameError: uninitialized constant DateTime
> from (irb):1
>
> At least some other classes (I tried File and Time) exist, so it is
> not that the
> installation were completely broken.
>
> What could be the problem here?

did you do a

require 'date'

before trying to access Date or DateTime. They are not part of
the Core classes that are automatically defined when Ruby starts up.


Ronald Fischer

8/21/2007 9:05:00 AM

0


> did you do a
>
> require 'date'
>
> before trying to access Date or DateTime. They are not part of
> the Core classes that are automatically defined when Ruby starts up.

OK, that solves it - but interestingly, a require 'date' is
not necessary when running under Windows (both in the native and
cygwin build of Ruby).

Ronald
--
Ronald Fischer <ronald.fischer@venyon.com>
Phone: +49-89-452133-162

John Joyce

8/21/2007 4:48:00 PM

0


On Aug 21, 2007, at 4:05 AM, Ronald Fischer wrote:

>
>> did you do a
>>
>> require 'date'
>>
>> before trying to access Date or DateTime. They are not part of
>> the Core classes that are automatically defined when Ruby starts up.
>
> OK, that solves it - but interestingly, a require 'date' is
> not necessary when running under Windows (both in the native and
> cygwin build of Ruby).
>
> Ronald
> --
> Ronald Fischer <ronald.fischer@venyon.com>
> Phone: +49-89-452133-162
>
That may mean it's loading all those libraries on windows even if you
don't need them...
You might run a test to see if methods from various libraries are
available.

Ronald Fischer

8/22/2007 8:16:00 AM

0

> > OK, that solves it - but interestingly, a require 'date' is
> > not necessary when running under Windows (both in the native and
> > cygwin build of Ruby).
> That may mean it's loading all those libraries on windows
> even if you
> don't need them...
> You might run a test to see if methods from various libraries are
> available.

I wonder whether this is really the "official" definition of Ruby that
date.rb must be required explicitly. On Linux, it isn't necessary
either,
and at least the Ruby books I have access to ("The Ruby Way" by Hal
Fulton
and "The Ruby Cookbook" by Richardson and Carlson) don't mention a
require 'date' when discussing the Date and DateTime classes...

Ronald
--
Ronald Fischer <ronald.fischer@venyon.com>
Phone: +49-89-452133-162