ywk_counter 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 716a849e512b9e4e0a7abb5598546b8f49f736dff4ca134b5918fad647b865b9
4
+ data.tar.gz: c3a0cc7f7dc22f69738da6326311bc9500b347348d5812c22dbf5f0f3ec6b693
5
+ SHA512:
6
+ metadata.gz: 955b59c299ea6896a45236be20136f62bee4c233bb6255971d8d24e6e9024e92c2d73b1f8baef8697ce30f2711837277dfa7e099a88dcc179d23be51df48e2fb
7
+ data.tar.gz: e2a670e8136fcc553958f064c407391bd77b4acf2a87c69d6e3ee72bee8a30043649972eaaaedfa82f4150fdee5e4f4f1940167fdcff84b05bc20e991d2a1345
@@ -0,0 +1,18 @@
1
+ module YwkCounter
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 YwkCounter
2
+ module Strategies
3
+ class Exponential
4
+ def initialize(exp: 2)
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 YwkCounter
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 YwkCounter
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
@@ -0,0 +1,4 @@
1
+ require "ywk_counter/counter"
2
+ require "ywk_counter/strategies/linear"
3
+ require "ywk_counter/strategies/multiplier"
4
+ require "ywk_counter/strategies/exponential"
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ywk_counter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - youngwoo ko
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2025-09-29 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: A Counter made by Ywk
13
+ email: 2012duddn@gmail.com
14
+ executables: []
15
+ extensions: []
16
+ extra_rdoc_files: []
17
+ files:
18
+ - lib/ywk_counter.rb
19
+ - lib/ywk_counter/counter.rb
20
+ - lib/ywk_counter/strategies/exponential.rb
21
+ - lib/ywk_counter/strategies/linear.rb
22
+ - lib/ywk_counter/strategies/multiplier.rb
23
+ homepage: http://rubygems.org/gems/ywk_counter
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '3.0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubygems_version: 3.6.2
42
+ specification_version: 4
43
+ summary: Ywk Counter!
44
+ test_files: []