Module: Fixjour::Counter
- Included in:
- Fixjour
- Defined in:
- lib/fixjour/counter.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.counter(key) ⇒ Object
12 13 14 |
# File 'lib/fixjour/counter.rb', line 12 def self.counter(key) @counters[key][] end |
.reset(key = nil) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/fixjour/counter.rb', line 3 def self.reset(key=nil) if key @counters[key] = lambda { s ||= 0; s += 1 } else @counters = Hash.new { |h,k| s ||= 0; c = lambda { s += 1 }; h[k] = c } end end |