On 22 May 2009, at 18:19, Jp Hastings-spital wrote:
> I'm attempting to build an ETA class, essentially identical to Time,  
> but
> where new accepts a number of seconds from now and generates the
> underlying Time object accordingly. Obviously I can't re-assign  
> self, so
> how should I do this?
>
> What I'd like to do:
> --
> class ETA < Time
>  def initialize(seconds)
>    self = Time.new + seconds
>  end
> end
> --
>
> Any help would be much appreciated!

How about something as simple as:

class ETA < Time
   def self.new
     ETA.at Time.now + seconds
   end
end


Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net
----
raise ArgumentError unless @reality.responds_to? :reason