Class: Fixjour::Counter
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Counter
constructor
A new instance of Counter.
- #next ⇒ Object
Constructor Details
#initialize ⇒ Counter
Returns a new instance of Counter.
22 23 24 |
# File 'lib/fixjour/counter.rb', line 22 def initialize @value = 0 end |
Class Method Details
.counter(key) ⇒ Object
8 9 10 11 |
# File 'lib/fixjour/counter.rb', line 8 def counter(key) counters[key] ||= new counters[key].next end |
.reset(key = nil) ⇒ Object
4 5 6 |
# File 'lib/fixjour/counter.rb', line 4 def reset(key=nil) key ? counters.delete(key) : counters.clear end |
Instance Method Details
#next ⇒ Object
26 27 28 |
# File 'lib/fixjour/counter.rb', line 26 def next @value += 1 end |