Download this source

class ExampleClass 
  # a class variable. These are treated specially, and
  # are not the same as instance variables on the Class.
  # 
  # Don't try to think about that too much yet...
  @@instcount = 0
  
  #constructor
  def initialize
    @@instcount += 1
  end
  
  def inst_count
    return @@instcount
  end
end

e1 = ExampleClass.new
e2 = ExampleClass.new

puts e1.inst_count

e3 = ExampleClass.new
puts e3.inst_count

e4 = e3
puts e3.inst_count

Running this outputs:

2
3
3