Skip to content

Instantly share code, notes, and snippets.

@mstahl
Created July 3, 2013 17:24
Show Gist options
  • Save mstahl/5920736 to your computer and use it in GitHub Desktop.
Save mstahl/5920736 to your computer and use it in GitHub Desktop.
Quick ActiveSupport-style monkey patch for fixnums when you're describing periods of time (in seconds)
class Fixnum
def seconds
self
end
alias :second :seconds
def minutes
self * 60.seconds
end
alias :minute :minutes
def hours
self * 60.minutes
end
alias :hour :hours
def days
self * 24.hours
end
alias :day :days
def weeks
self * 7.days
end
alias :week :weeks
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment