Skip to content

Instantly share code, notes, and snippets.

@CodeOfficer
Created March 3, 2009 05:45
Show Gist options
  • Save CodeOfficer/73207 to your computer and use it in GitHub Desktop.
Save CodeOfficer/73207 to your computer and use it in GitHub Desktop.
# 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