Sha256: 710b9af454d55f74f01965551c7d8087c3ddb69655a7123e53142027e0223151

Contents?: true

Size: 348 Bytes

Versions: 2

Compression:

Stored size: 348 Bytes

Contents

require "calc/version"

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.3 lib/calc.rb
calc-nik-0.0.2 lib/calc.rb