class Counter

Implements a simple accumulator, whose value is accessed via the attribute counter. Calling the method Counter#inc increments this value.

Attributes

counter[R]

The current value of the count

Public Class Methods

new(initial_value=0) click to toggle source

create a new Counter with the given initial value

# File counter.rb, line 11
def initialize(initial_value=0)
  @counter = initial_value
end

Public Instance Methods

inc() click to toggle source

increment the current value of the count

# File counter.rb, line 16
def inc
  @counter += 1
end