lib/calc.rb in calc-nik-0.0.1 vs lib/calc.rb in calc-nik-0.0.2
- old
+ new
@@ -1,7 +1,29 @@
require "calc/version"
module Calc
- def self.meth
- 42
+ class Calc
+ def initialize
+ @numbers = Array.new
+ end
+
+ def get(*args)
+ @numbers.push(args).flatten!
+ end
+
+ def plus
+ res = @numbers.reduce(&:+)
+ wipe
+ res || 0
+ end
+
+ def minus
+ - plus
+ end
+
+ private
+
+ def wipe
+ @numbers = []
+ end
end
end