Class: TypableMap::Counter

Inherits:
Object
  • Object
show all
Defined in:
lib/typable_map/counter.rb

Instance Method Summary collapse

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

#nextObject



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