From: David Bailey <david.bailey / technologist.com>
Subject: Re: Callback For A Timer Event To Display Widget in Ruby/Tk
Date: Tue, 28 Mar 2006 20:17:14 +0900
Message-ID: <b34e30884066f0651439cca5e87f0053 / ruby-forum.com>
> I have two quick questions: will my creation of all those Time.new 
> objects (two per second) cause me to run out of resources if I do it for 
> a long time?

Probably, if you don't keep any references for those Time objects, 
GC will release the resources of those objects.

> Secondly, while this 'elapsed time' code works:
> 
> "Elapsed is #{(Time.at(Time.new.to_i - (oldTime.to_i - 
> 18000))).strftime("%X")}"
> 
> I have a sneaky feeling that it is not the best (Ruby?) way.  Is it way 
> too resource wasteful, and if so, is there a more "Ruby" way?

I think the following returns the same result as yours.
-------------------------------------------------------------
basetime = (Time.now - 18000).to_f  # instead of "oldTime"

"Elapsed is #{(Time.now - basetime).strftime("%X")}"
-------------------------------------------------------------
-- 
Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)