Created
June 23, 2010 20:54
-
-
Save patrick99e99/450533 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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