class Clovek
# static field
@@people_count = 0
# static method
def self.howmany()
@@people_count
end
# a constructor
def initialize(name, age)
@name = name
@age = age
@@people_count += 1
end
# getter
def name
@name
end
def age
@age
end
# a method
def whoami()
puts "Hello, my name is #{@name}, I am #{@age} years old."
end
end
dan = Clovek.new("Daniel", 31)
dan.whoami()
simon = Clovek.new("Simon", "?")
simon.whoami()
puts "Number of people: #{Clovek.howmany()}"