Skip to content

Instantly share code, notes, and snippets.

@toddseller
Last active December 21, 2015 15:10
Show Gist options
  • Save toddseller/9e65e3cbb8322c855b38 to your computer and use it in GitHub Desktop.
Save toddseller/9e65e3cbb8322c855b38 to your computer and use it in GitHub Desktop.
Defining the bored method
class Dog
def initialize(name, breed)
@name = name
@breed = breed
@hungry = false
@bored = false
end
def feed
puts "You just fed #{@name}, the #{@breed}."
@hungry = false
@bored = true
end
def bored
puts "You just played fetch with #{@name}, the #{@breed}."
@bored = false
end
end
puppy = Dog.new('Atticus', 'German Shepherd')
puppy.feed
>> "You just fed Atticus, the German Shepherd."
puppy.bored
>> "You just played fetch with Atticus, the German Shepherd."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment