Re. NameError: uninitialized constant Date::ABBR_MONTHS

Discussion in 'Ruby' started by Chris Duncan, Apr 11, 2007.

  1. Chris Duncan

    Chris Duncan Guest

    Jigar Gosar wrote:

    >
    > DATE::ABBR_MONTHS exists in this doc here.
    > http://www.ruby-doc.org/stdlib/libdoc/date/rdoc/index.html
    > Still I get the error.
    >
    >
    >> ruby -v
    >>

    > ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
    >
    >
    > irb(main):001:0> require "date"
    > => true
    > irb(main):002:0> Date::MONTHNAMES
    > => [nil, "January", "February", "March", "April", "May", "June",
    > "July",
    > "August", "September", "October", "November", "December"]
    > irb(main):003:0> DATE::ABBR_MONTHS
    > NameError: uninitialized constant DATE
    > from (irb):3
    > irb(main):004:0>
    >
    >
    >
    > DATE::ABBR_MONTHS exists in this doc here.
    > http://www.ruby-doc.org/stdlib/libdoc/date/rdoc/index.html
    >
    > And I was using this functionality till ruby 1.8.2 it suddenly stoped
    > with the upgrade. can these guys just remove stuff without
    > warning!!! or
    > am I looking at wrong place?
    >
    > Please help


    Hi Gosar,

    In your irb example you have DATE::ABBR_MONTHS instead of
    Date::ABBR_MONTHS. In this case Ruby interprets DATE as a constant
    instead of a class, therefore you get an error. Here's my output:

    irb(main):001:0> require 'date'
    => true
    irb(main):002:0> Date::ABBR_MONTHS
    => {"oct"=>10, "jul"=>7, "jan"=>1, "dec"=>12, "jun"=>6, "apr"=>4,
    "feb"=>2, "may"=>5, "sep"=>9, "aug"=>8, "mar"=>3, "nov"=>11}
    irb(main):003:0> DATE::ABBR_MONTHS
    NameError: uninitialized constant DATE
    from (irb):3


    HTH.

    Regards,

    Chris
    http://rotsog.wordpress.com
     
    Chris Duncan, Apr 11, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel
    Replies:
    2
    Views:
    476
    Daniel
    Jun 22, 2006
  2. Jose Pepe
    Replies:
    1
    Views:
    156
    Jose Pepe
    Jul 16, 2006
  3. Reid Thompson
    Replies:
    0
    Views:
    115
    Reid Thompson
    Oct 21, 2006
  4. Vikash Kumar
    Replies:
    2
    Views:
    119
    Vikash Kumar
    Nov 6, 2006
  5. Jigar Gosar
    Replies:
    8
    Views:
    143
    Khurram Virani
    Apr 3, 2008
Loading...

Share This Page