Class: Calc::Calc

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

Instance Method Summary collapse

Constructor Details

#initializeCalc

Returns a new instance of Calc.



5
6
7
# File 'lib/calc.rb', line 5

def initialize
  @numbers = Array.new
end

Instance Method Details

#get(*args) ⇒ Object



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

def get(*args)
  @numbers.push(args).flatten!
end

#minusObject



19
20
21
# File 'lib/calc.rb', line 19

def minus
  - plus
end

#plusObject



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

def plus
  res = @numbers.reduce(&:+)
  wipe
  res || 0
end