From: Niklas Frykholm Date: 2003-11-28T17:52:08+09:00 Subject: Re: Time#succ ? >>anyone familiar with the 'jot' unix program? i think ranges should work like >>that - eg. one should be able to define the increment >> >>day = 60 * 60 * 24 >> >>a = Time.now >>b = Time.now + (7 * day) >> >>week = (a...b) >> >>week.each(step = day) do |weekday| >> ... >>end I think a rather nice way of doing this is "by example": def loop_over(v1,v2,vn) x = v1 step = v2 - v1 while x <= vn yield x x += step end end loop_over(1,2,10) {|x| puts x} # -> 1,2,3,4,5,6,7,8,9,10 day = 60 * 60 * 24 t = Time.now loop_over(t, t + day, t + 7*day) do |weekday| // Niklas