calc-nik 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +8 -0
  2. data/lib/calc/version.rb +1 -1
  3. data/lib/calc.rb +24 -2
  4. metadata +1 -1
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
+ #!/usr/bin/env rake
1
2
  require "bundler/gem_tasks"
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'lib/calc'
6
+ t.test_files = FileList['spec/*_spec.rb']
7
+ t.verbose = true
8
+ end
9
+ task :default => :test
data/lib/calc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Calc
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/calc.rb CHANGED
@@ -1,7 +1,29 @@
1
1
  require "calc/version"
2
2
 
3
3
  module Calc
4
- def self.meth
5
- 42
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calc-nik
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: