Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > When was the parse method added to the Time class?

Reply
Thread Tools

When was the parse method added to the Time class?

 
 
Paul
Guest
Posts: n/a
 
      03-13-2009
Hi there, I've been running a particular script for a few years now
and only just noticed that it crashes on one particular system. (I
don't use that system very often and have run that script on it very
rarely.)

The offending code/line in question uses the Time.parse method.

I opened a CMD prompt and tried the following:
----
irb(main):001:0> d = '03/13/09 14:52'
=> "03/13/09 14:52"
irb(main):002:0> Time.parse( d )
NoMethodError: undefined method `parse' for Time:Class
from (irb):2
....
irb(main):010:0> Time.methods.include? 'parse'
=> false
----

This system has Ruby 184-20 installed. I know that version 186-25 and
up have the Time.parse method and the script works fine. However, I
want to know what version of Ruby first included that method so that I
can identify the minimum requirements to run the script.

Can anyone tell me how I might find out what version/release of Ruby
first included that method?

Please let me know. Thanks.

Paul.
 
Reply With Quote
 
 
 
 
Joel VanderWerf
Guest
Posts: n/a
 
      03-13-2009
Paul wrote:
> Hi there, I've been running a particular script for a few years now
> and only just noticed that it crashes on one particular system. (I
> don't use that system very often and have run that script on it very
> rarely.)
>
> The offending code/line in question uses the Time.parse method.
>
> I opened a CMD prompt and tried the following:
> ----
> irb(main):001:0> d = '03/13/09 14:52'
> => "03/13/09 14:52"
> irb(main):002:0> Time.parse( d )
> NoMethodError: undefined method `parse' for Time:Class
> from (irb):2
> ...
> irb(main):010:0> Time.methods.include? 'parse'
> => false
> ----
>
> This system has Ruby 184-20 installed. I know that version 186-25 and
> up have the Time.parse method and the script works fine. However, I
> want to know what version of Ruby first included that method so that I
> can identify the minimum requirements to run the script.
>
> Can anyone tell me how I might find out what version/release of Ruby
> first included that method?
>
> Please let me know. Thanks.
>
> Paul.


It's not a ruby version issue.

Confusingly, Time.parse is only available after explicitly requiring 'time':

irb(main):001:0> Time.parse "1:23"
NoMethodError: undefined method `parse' for Time:Class
from (irb):1
irb(main):002:0> require 'time'
=> true
irb(main):003:0> Time.parse "1:23"
=> Fri Mar 13 01:23:00 -0700 2009

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

 
Reply With Quote
 
 
 
 
Paul Carvalho
Guest
Posts: n/a
 
      03-13-2009
Joel wrote:

> It's not a ruby version issue.
>
> Confusingly, Time.parse is only available after explicitly requiring 'time':
>
> irb(main):001:0> Time.parse "1:23"
> NoMethodError: undefined method `parse' for Time:Class
> * * * * *from (irb):1
> irb(main):002:0> require 'time'
> => true
> irb(main):003:0> Time.parse "1:23"
> => Fri Mar 13 01:23:00 -0700 2009
>


Hmm, okay. I get that. So why does the "Time.methods.include?
'parse'" line work on all the other systems except for one? I'm not
specifically requiring that class on the other machines.

As a test, I uninstalled Ruby 184 and installed Ruby 186 and I get the
same effect on this computer -- i.e. the Time.parse method is still
not there by default. Weird. Could another Ruby gem be causing the
problem?

Paul.
 
Reply With Quote
 
Paul Carvalho
Guest
Posts: n/a
 
      03-13-2009
>
> As a test, I uninstalled Ruby 184 and installed Ruby 186 and I get the
> same effect on this computer -- i.e. the Time.parse method is still
> not there by default. *Weird. *Could another Ruby gem be causing the
> problem?
>


Okay, I uninstalled Ruby again and reinstalled it. This time I wrote
a one-line script with the above Time.parse code so that I could run
it anytime.

I installed all the gems I needed and the Time.parse method is always
there and works as expected.

The one thing I did the last time that I *didn't* do this time was run
the command:
> gem update --system


If I run the above, then the Time.parse method will no longer be
available by default. It looks like there is something in that update
that kills the parse method for the Time class.

I won't be updating my rubygems again unless there is some compelling
reason for me to.

At least now I know what caused this system to stop running that
script.


 
Reply With Quote
 
Justin Collins
Guest
Posts: n/a
 
      03-14-2009
Paul Carvalho wrote:
>> As a test, I uninstalled Ruby 184 and installed Ruby 186 and I get the
>> same effect on this computer -- i.e. the Time.parse method is still
>> not there by default. Weird. Could another Ruby gem be causing the
>> problem?
>>
>>

>
> Okay, I uninstalled Ruby again and reinstalled it. This time I wrote
> a one-line script with the above Time.parse code so that I could run
> it anytime.
>
> I installed all the gems I needed and the Time.parse method is always
> there and works as expected.
>
> The one thing I did the last time that I *didn't* do this time was run
> the command:
>
>> gem update --system
>>

>
> If I run the above, then the Time.parse method will no longer be
> available by default. It looks like there is something in that update
> that kills the parse method for the Time class.
>
> I won't be updating my rubygems again unless there is some compelling
> reason for me to.
>
> At least now I know what caused this system to stop running that
> script.
>


Probably the newer version of one of your gems stopped including the
Time library.

-Justin

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
undefined method `parse' for Time:Class Error Srikanth Jeeva Ruby 8 12-10-2008 09:23 AM
Solution for posterity: GridView, Datakeys, and "Item has already been added. Key in dictionary: 'CategoryID' Key being added: 'CategoryID'" ASP .Net 2 11-02-2006 04:48 AM
Parse children for Template added at design time Repoleved ASP .Net Building Controls 0 05-13-2005 06:08 PM
how come user control added to page doesn't get added to codebehind file? Bennett Haselton ASP .Net 1 11-08-2004 09:26 PM
Newly added asp.net webforms cannot parse Do ASP .Net 1 10-22-2003 07:45 AM



Advertisments