Skip to content

Instantly share code, notes, and snippets.

@fuse
Created May 31, 2011 10:35
Show Gist options
  • Save fuse/1000283 to your computer and use it in GitHub Desktop.
Save fuse/1000283 to your computer and use it in GitHub Desktop.
class Animal
attr_accessor :name, :age, :weight
def initialize(name, weight, age)
@name = name
@weight = weight
@age = age
end
def to_s
"I'm #{name}, I have #{age} years and I weigh #{weight} KG."
end
def older?(animal)
age > animal.age
end
def bigger?(animal)
weight > animal.weight
end
protected :age
private :weight
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment