Class: CalculatorGem::Calculator

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

Class Method Summary collapse

Class Method Details

.add(*args) ⇒ Object



3
4
5
# File 'lib/calculator_gem.rb', line 3

def self.add *args
    args.inject(:+)
end

.divide(a, b) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/calculator_gem.rb', line 12

def self.divide(a, b)
  if b == 0
    raise ZeroDivisionError.new("Cannot divide by zero")
  else
    a / b
  end
end

.multiplication(*args) ⇒ Object



9
10
11
# File 'lib/calculator_gem.rb', line 9

def self.multiplication *args
    args.inject(:*)
end

.remove(*args) ⇒ Object



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

def self.remove *args
    args.inject(:-)
end