rapeech_counter 0.0.1 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffdb23c1e0cd1805e8f6fc9e55c64b9bd9a8b741f83abdc70eaaba7019572608
4
- data.tar.gz: 99f313d217ad4b8e201aceb03b5aa1b8cc0b6dc8537279ab33ba1274dba104ba
3
+ metadata.gz: 12d11c88e8d79b7ddbcfa317a93a6ee46914a37d3a8e8712ffa9f732b23ca4a9
4
+ data.tar.gz: 4a83c0ffa2ab0ec5dd3cfdece16522079120eb7d724647729bf4e87545c689d8
5
5
  SHA512:
6
- metadata.gz: 93d916915244c47785bdbe6b2d5f56f5c8c6bc8c4c959af5553e3e4cb2463f493cfbc709d4067131f9715aaf497285e0325e6042d1e0882013a10e25a910ad49
7
- data.tar.gz: 8c73e5d93c09ec09a72b73108e33f76838030deadf3c3cf54635b79576de7e88e248d2fd9d4b8e62348af56bda475ed2097930079e2f3479e27b9eabad02dca3
6
+ metadata.gz: 94f724f5e4a025d573b5d91e7ffedcd5e9162e2c9b7db3767d8c60de44d1433ef447fe7185e563050a488e01d807d41ce460dc8cc49a6956e22a2edc5cd71f2e
7
+ data.tar.gz: bf415a61fa4b543d1a822c1ab72962ecd50798a79422ee131b7b924bcce8acccc5f6984d21ee40cb141dd163257f912b9ced60595fb1df47d336886ba1308e08
@@ -0,0 +1,18 @@
1
+ module RapeechCounter
2
+ class Counter
3
+ attr_reader :value
4
+
5
+ def initialize(strategy:, initial: 0)
6
+ @strategy = strategy
7
+ @value = initial
8
+ end
9
+
10
+ def increment
11
+ @value = @strategy.increment(@value)
12
+ end
13
+
14
+ def reset(initial = 0)
15
+ @value = initial
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ module RapeechCounter
2
+ module Strategies
3
+ class Exponential
4
+ def initialize(exp)
5
+ @exp = exp
6
+ end
7
+
8
+ def increment(value)
9
+ value ** @exp
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module RapeechCounter
2
+ module Strategies
3
+ class Linear
4
+ def initialize(step=1)
5
+ @step = step
6
+ end
7
+
8
+ def increment(value)
9
+ value + @step
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module RapeechCounter
2
+ module Strategies
3
+ class Multiplier
4
+ def initialize(factor = 2)
5
+ @factor = factor
6
+ end
7
+
8
+ def increment(value)
9
+ value * @factor
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,11 +1,4 @@
1
- class RapeechCounter
2
- @@a = 0
3
-
4
- def self.add
5
- @@a += 1
6
- end
7
-
8
- def self.a
9
- @@a
10
- end
11
- end
1
+ require "rapeech_counter/counter"
2
+ require "rapeech_counter/strategies/linear"
3
+ require "rapeech_counter/strategies/multiplier"
4
+ require "rapeech_counter/strategies/exponential"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapeech_counter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - youngwoo ko
@@ -16,6 +16,10 @@ extensions: []
16
16
  extra_rdoc_files: []
17
17
  files:
18
18
  - lib/rapeech_counter.rb
19
+ - lib/rapeech_counter/counter.rb
20
+ - lib/rapeech_counter/strategies/exponential.rb
21
+ - lib/rapeech_counter/strategies/linear.rb
22
+ - lib/rapeech_counter/strategies/multiplier.rb
19
23
  homepage: http://rubygems.org/gems/rapeech_counter
20
24
  licenses:
21
25
  - MIT