[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01983] Re: Time::at

From: Hugh Sasse Staff Elec Eng <hgs@...>
Date: 2000-03-17 18:25:35 UTC
List: ruby-talk #1983
On Fri, 17 Mar 2000, David Douthitt wrote:

> or whatever the right syntax is :-)
> 
> The ruby 1.4 manual says this:
> 
> at(time)  Creates the time object at time. The argument time must be
> either the instance of the Time class or the number, which is
> considered as seconds since 00:00:00 GMT, January 1, 1970.
> 
> However, this line:
> 
>    print ">>>>", at(57827), "\n";

	You have not used it as a method of anything.  So it is looking 
	for a method of Object.
> 
> Generates this error:
> 
> ./ppp-time.rb:105: undefined method `at' for #<Object:0x40181ed4> (NameError)
>         from ./ppp-time.rb:102:in `each'
>         from ./ppp-time.rb:102
> 
> Two things I note - 57827 should be of class "Fixnum" not "Object"

	It is, the Fixnum is the argument of the method.  The method
	on works for class Time.

> right?  Secondly, I get the same error if I send a string to to_i .  
> What is going on?
> 
> I'm trying to convert a string of the seconds since the epoch into a time object.
> 

ruby> t = Time.new()
Fri Mar 17 18:16:44 GMT 2000
ruby> print t.at(57827)
ERR: (eval):1: undefined method `at' for Fri Mar 17 18:16:44 GMT 2000:Time
ruby> t.type
Time

Re-examining the manual, at is a class method of Time, not an instance
method.

ruby> t2=Time.at(57827)
Thu Jan 01 17:03:47 BST 1970
ruby> > 

	Hugh
	hgs@dmu.ac.uk



In This Thread