From: Matthew Kerwin Date: 2012-09-13T20:37:31+09:00 Subject: Re: ruby Range to array that acts like time objects? I'd create a class, maybe `class HoursMinutes`, which has @hour and @minute properties, defines a #<=> comparison method and a #succ that increments @minute with overflow into @hour. Then I'd make the range `HoursMinutes.new(8,0)..HoursMinutes.new(9,0)` But that's just me. On 13 September 2012 21:31, Jermaine O. wrote: > Hello everybody, > > I'm looking for a way to create an array out of a range, but does the > counting as like it's a time object. So for instance: > > (800..900).to_a (which represents: 08:00 - 09:00) > will generate an array something like this: > > #=> [800,801,802,...... 899, 900] > > Whereas I would like the output to be like this: > > #=> [800,801,802,...... 859, 900] > > Basically it should bump to the next major number (hour) after 59 > instead of going all the way up to 99. > > How should I go about doing this? > > Thanks! > > -- > Posted via http://www.ruby-forum.com/. > -- Matthew Kerwin, B.Sc (CompSci) (Hons) http://matthew.kerwin.net.au/ ABN: 59-013-727-651 "You'll never find a programming language that frees you from the burden of clarifying your ideas." - xkcd