Skip to content

Instantly share code, notes, and snippets.

@perspectivezoom
Created June 12, 2012 22:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perspectivezoom/2920664 to your computer and use it in GitHub Desktop.
Save perspectivezoom/2920664 to your computer and use it in GitHub Desktop.
module Calculator
def add(n)
self + n
end
def subtract(n)
self-n
end
def multiply_by(n)
self * n
end
alias :multiply :multiply_by
def divided_by(n)
self.to_f / n
end
alias :divide :divided_by
end
class Numeric
include Calculator
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment