Sha256: 3572aff14a6b8093eee63f4815128151b9dc9808f59769e3e68251486e416967

Contents?: true

Size: 368 Bytes

Versions: 2

Compression:

Stored size: 368 Bytes

Contents

require 'calc/version'
require 'calc/calc'

module Calc
  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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
calc-nik-0.0.5 lib/calc.rb
calc-nik-0.0.4 lib/calc.rb