Class: Calculator

Inherits:
Object
  • Object
show all
Defined in:
lib/calculator.rb

Instance Method Summary collapse

Instance Method Details

#add(a, b) ⇒ Object



2
3
4
# File 'lib/calculator.rb', line 2

def add(a, b)
  a + b
end

#divide(a, b) ⇒ Object



14
15
16
17
# File 'lib/calculator.rb', line 14

def divide(a, b)
  raise "Division by zero" if b == 0
  a.to_f / b
end

#multiply(a, b) ⇒ Object



10
11
12
# File 'lib/calculator.rb', line 10

def multiply(a, b)
  a * b
end

#subtract(a, b) ⇒ Object



6
7
8
# File 'lib/calculator.rb', line 6

def subtract(a, b)
  a - b
end