Skip to content

Instantly share code, notes, and snippets.

@MichaelCPell
Created February 13, 2015 19:47
Show Gist options
  • Select an option

  • Save MichaelCPell/36b397f8c7c63d392c52 to your computer and use it in GitHub Desktop.

Select an option

Save MichaelCPell/36b397f8c7c63d392c52 to your computer and use it in GitHub Desktop.
class Calculator
def self.description
"Performs basic mathematical operations"
end
# def instance methods
# calc = Calculator.new(7,2)
# end
def initialize(x, y)
@x = x
@y = y
end
def add
@x + @y
end
def subtract
@x - @y
end
def multiply
@x * @y
end
def divide
@x.to_f / @y
end
end
# puts calc.description
# puts calc. add
# puts calc.subtract
# puts calc.multiply
# puts calc.divide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment