Class: TypableMap::Counter
- Inherits:
-
Object
- Object
- TypableMap::Counter
- Defined in:
- lib/typable_map/counter.rb
Instance Method Summary collapse
-
#initialize(max_count = 100) ⇒ Counter
constructor
A new instance of Counter.
- #next ⇒ Object
Constructor Details
#initialize(max_count = 100) ⇒ Counter
Returns a new instance of Counter.
6 7 8 9 |
# File 'lib/typable_map/counter.rb', line 6 def initialize(max_count = 100) @n = 0 @max_count = max_count end |
Instance Method Details
#next ⇒ Object
11 12 13 14 15 16 |
# File 'lib/typable_map/counter.rb', line 11 def next retval = @n @n += 1 @n = @n % @max_count retval end |