Ruby Classes
A Ruby class defines the behavior of its objects. initialize runs when you call Counter.new, and instance variables that start with @ belong to one object.
Ruby
class Counter
attr_reader :value
def initialize
@value = 0
end
def increment
@value += 1
end
end
counter = Counter.new
counter.increment
counter.increment
puts counter.value