Created
April 27, 2009 03:00
-
-
Save nikz/102297 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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