John Joyce
8/20/2007 8:53:00 PM
On Aug 20, 2007, at 3:07 PM, Felix Windt wrote:
>> -----Original Message-----
>> From: Ronny [mailto:ro.naldfi.scher@gmail.com]
>> Sent: Monday, August 20, 2007 12:50 PM
>> To: ruby-talk ML
>> Subject: Date and DateTime on the Mac
>>
>> 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
>>
>>
>
> Date/DateTime need to be required and aren't automatically loaded.
>
> require 'date'
> now = DateTime.now
It is part of the Ruby 'standard library' but you do still need to
require a library before using it.
If you are not sure if a method is available, that is, you don't know
if it has been required, use irb.
in irb try the method. Error message? then try require 'library_name'
and it will return true on success, false on failure.
If it returns false, you might have mistyped the name, or path to the
library.