Skip to content

Instantly share code, notes, and snippets.

@nikz
Created April 27, 2009 03:00
Show Gist options
  • Select an option

  • Save nikz/102297 to your computer and use it in GitHub Desktop.

Select an option

Save nikz/102297 to your computer and use it in GitHub Desktop.
class Time
def with_interval_of(interval)
@interval = interval
self
end
def succ
@interval ||= 1
returning(self + @interval) do |t|
t.with_interval_of(@interval)
end
end
end
>> (Time.now.with_interval_of(1.day)...(Time.now + 5.days).with_interval_of(1.day)).each do |t|
?> puts t
>> end
Mon Apr 27 14:59:32 +1200 2009
Tue Apr 28 14:59:32 +1200 2009
Wed Apr 29 14:59:32 +1200 2009
Thu Apr 30 14:59:32 +1200 2009
Fri May 01 14:59:32 +1200 2009
Sat May 02 14:59:32 +1200 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment