Skip to content

Instantly share code, notes, and snippets.

@patrick99e99
Created June 23, 2010 20:54
Show Gist options
  • Save patrick99e99/450533 to your computer and use it in GitHub Desktop.
Save patrick99e99/450533 to your computer and use it in GitHub Desktop.
class Dog
def initialize(options = {})
@name = options[:name]
@color = options[:color]
@breed = options[:breed]
@hair = options[:hair]
@size = options[:size]
end
def description
"#{@name} is a #{@size} #{@color} #{hair} haired #{breed}."
end
def speak(bark)
"#{@name} says \"#{bark}!\""
end
end
puppy = Dog.new(:name => "Lucky", :color => "black", :breed => "Australian
Shepherd",:hair => "long", :size => "big")
puppy.description
=> "Lucky is a big black long haired Australian Shepherd."
puppy.speak("Woof!")
=> "Lucky says "Woof!""
puppy.speak("(Squeaky Wheel")
=> "Lucky says "Squeaky Wheel!""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment