Yeah thanks! Just after I posted it I remembered my pascal (or similar) days and step came into mind ...
(@info[0][1].. @info[0][2]).step(15.minutes) do |i| Seemed to do the trick nicely! On 5 June, 22:23, Rob Biedenharn <[email protected]> wrote: > On Jun 5, 2009, at 5:04 PM, Ruby on Rails: Talk wrote: > > > > > > > Hi > > > I'm sure I've read somewhere that you can count up in 'jumps' using > > ruby? > > > I've got two times and I want to basically go up in 15 minute jumps > > without using the whole for loop thing. > > > Any helpful ideas? All my ruby books are in storage and I can't find > > anything on google ...but then I'm not sure what I'm looking for! > > > Thanks in advance. > > > Code: > > > <%- (@info[0][1].. @info[0][2]).???? do %> > > > Darren > > Something like Numeric#step > > irb> require 'rubygems' > => true > irb> require 'activesupport' > => true > irb> start_time = 10.minutes.from_now > => Fri Jun 05 17:26:49 -0400 2009 > irb> end_time = 4.hours.since start_time > => Fri Jun 05 21:26:49 -0400 2009 > irb> start_time.to_i.step(end_time.to_i, 15.minutes) do |sec| puts > Time.at(sec); end > Fri Jun 05 17:26:49 -0400 2009 > Fri Jun 05 17:41:49 -0400 2009 > Fri Jun 05 17:56:49 -0400 2009 > Fri Jun 05 18:11:49 -0400 2009 > Fri Jun 05 18:26:49 -0400 2009 > Fri Jun 05 18:41:49 -0400 2009 > Fri Jun 05 18:56:49 -0400 2009 > Fri Jun 05 19:11:49 -0400 2009 > Fri Jun 05 19:26:49 -0400 2009 > Fri Jun 05 19:41:49 -0400 2009 > Fri Jun 05 19:56:49 -0400 2009 > Fri Jun 05 20:11:49 -0400 2009 > Fri Jun 05 20:26:49 -0400 2009 > Fri Jun 05 20:41:49 -0400 2009 > Fri Jun 05 20:56:49 -0400 2009 > Fri Jun 05 21:11:49 -0400 2009 > Fri Jun 05 21:26:49 -0400 2009 > => 1244237209 > > You have to go from Time => Fixnum => Time, but you can adjust to your > specifics. > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > [email protected] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

