calc-nik 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +8 -0
- data/lib/calc/version.rb +1 -1
- data/lib/calc.rb +24 -2
- metadata +1 -1
    
        data/Rakefile
    CHANGED
    
    
    
        data/lib/calc/version.rb
    CHANGED
    
    
    
        data/lib/calc.rb
    CHANGED
    
    | @@ -1,7 +1,29 @@ | |
| 1 1 | 
             
            require "calc/version"
         | 
| 2 2 |  | 
| 3 3 | 
             
            module Calc
         | 
| 4 | 
            -
               | 
| 5 | 
            -
                 | 
| 4 | 
            +
              class Calc
         | 
| 5 | 
            +
                def initialize
         | 
| 6 | 
            +
                  @numbers = Array.new
         | 
| 7 | 
            +
                end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                def get(*args)
         | 
| 10 | 
            +
                  @numbers.push(args).flatten!
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def plus
         | 
| 14 | 
            +
                  res = @numbers.reduce(&:+)
         | 
| 15 | 
            +
                  wipe
         | 
| 16 | 
            +
                  res || 0
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def minus
         | 
| 20 | 
            +
                  - plus
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                private
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                def wipe
         | 
| 26 | 
            +
                  @numbers = []
         | 
| 27 | 
            +
                end
         | 
| 6 28 | 
             
              end
         | 
| 7 29 | 
             
            end
         |