Chris Shea wrote:
> You might want to take a look at the Duration gem: 
> http://rubyforge.org/projects/duration/
> 
> It's very similar to what you have here.

Damn it! That makes so much more sense! Just like Ruby makes the concept 
of a range explicit via Range, I should have thought to make _duration_ 
(brilliant name, by the way) explicit via Duration.

Objects, Daniel, objects! Not objects grafted as methods onto other 
objects!

Here's an excerpt from the doc:

require 'duration'
=> true
d = Duration.new(60 * 60 * 24 * 10 + 120 + 30)
=> #<Duration: 1 week, 3 days, 2 minutes and 30 seconds>
d.to_s
=> "1 week, 3 days, 2 minutes and 30 seconds"
[d.weeks, d.days]
=> [1, 3]
d.days = 7; d
=> #<Duration: 2 weeks, 2 minutes and 30 seconds>
d.strftime('%w w, %d d, %h h, %m m, %s s')
=> "2 w, 0 d, 0 h, 2 m, 30 s"

And a direct link to the docs:
http://duration.rubyforge.org/doc/

Thanks Chris for pointing this out to me.
-- 
Posted via http://www.ruby-forum.com/.