Class: Calc::Calc
- Inherits:
-
Object
- Object
- Calc::Calc
- Defined in:
- lib/calc.rb
Instance Method Summary collapse
- #get(*args) ⇒ Object
-
#initialize ⇒ Calc
constructor
A new instance of Calc.
- #minus ⇒ Object
- #plus ⇒ Object
Constructor Details
#initialize ⇒ Calc
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 |
#minus ⇒ Object
19 20 21 |
# File 'lib/calc.rb', line 19 def minus - plus end |
#plus ⇒ Object
13 14 15 16 17 |
# File 'lib/calc.rb', line 13 def plus res = @numbers.reduce(&:+) wipe res || 0 end |