Created
January 7, 2012 20:08
-
-
Save mungomash/1575865 to your computer and use it in GitHub Desktop.
Adding additional methods in Ruby
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
require 'date' | |
class Weeks | |
def initialize(number) | |
@number = number | |
end | |
def ago | |
return Date.today - (@number * 7) | |
end | |
end | |
class Fixnum | |
def weeks | |
return Weeks.new(self) | |
end | |
end | |
puts 2.weeks.ago |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment