Created
March 3, 2009 05:45
-
-
Save CodeOfficer/73207 to your computer and use it in GitHub Desktop.
This file contains 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
# another great snippet courtesy of http://heypanda.com/ | |
class Fixnum | |
# returns seconds | |
def hours | |
self * 3600 | |
end | |
end | |
def forever | |
while true | |
yield | |
end | |
end | |
def work(intensity) | |
puts "You worked #{intensity}!" | |
end | |
def play(intensity) | |
puts "You played #{intensity}!" | |
end | |
# sleep is a Kernel method. Alias before overriding. | |
alias :old_sleep :sleep | |
def sleep(time) | |
old_sleep(time) | |
puts "You slept for #{time} seconds!" | |
end | |
# And the original code... | |
forever do | |
work :hard | |
play :hard | |
sleep 5.hours | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment