From: Robert Klemme Date: 2009-05-25T03:00:08+09:00 Subject: Re: Workarounds for replacing self On 24.05.2009 19:39, Jp Hastings-spital wrote: > Robert Klemme wrote: >> class ETA < Time >> # Takes a number of seconds until the event >> def self.relative(seconds) >> at Time.now.to_i + seconds >> end > .. >> end > > Thanks for the tips! Out of interest, why did you change my self.new > method to self.relative? Is that personal preference, or is there a > reason you've kept Time's original .new and .now? Your ETA.new does something different than Time.new and because of that a new name would help avoid confusion. Also, by that means you can still use the "old" new with the old semantics, i.e. you can do ETA.new and get an instance with the current timestamp. You could even put relative in class Time and use it both ways: def Time.relative(sec) at now + sec end class ETA < Time # other instance methods end t = Time.relative 123 e = ETA.relative 123 p t, t.class, e, e.class Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/