class Counter
Implements a simple accumulator, whose value is accessed via the attribute counter. Calling the method Counter#inc increments this value.
Attributes
The current value of the count
Public Class Methods
Source
# File counter.rb, line 11 def initialize(initial_value = 0) @counter = initial_value end
create a new Counter with the given initial value
Public Instance Methods
Source
# File counter.rb, line 16 def inc @counter += 1 end
increment the current value of the count