Class: Kitchen::Counter
Overview
A simple counting object
hehe
Instance Method Summary collapse
-
#get ⇒ Integer
Returns the value of the counter.
-
#increment(by: 1) ⇒ Object
(also: #inc)
Increase the value of the counter.
-
#initialize ⇒ Counter
constructor
Creates a new
Counter
instance. -
#reset(to: 0) ⇒ Object
Reset the value of the counter.
Constructor Details
#initialize ⇒ Counter
Creates a new Counter
instance
10 11 12 |
# File 'lib/kitchen/counter.rb', line 10 def initialize reset end |
Instance Method Details
#get ⇒ Integer
Returns the value of the counter
29 30 31 |
# File 'lib/kitchen/counter.rb', line 29 def get @value end |
#increment(by: 1) ⇒ Object Also known as: inc
Increase the value of the counter
18 19 20 |
# File 'lib/kitchen/counter.rb', line 18 def increment(by: 1) @value += by end |
#reset(to: 0) ⇒ Object
Reset the value of the counter
36 37 38 |
# File 'lib/kitchen/counter.rb', line 36 def reset(to: 0) @value = to end |