Skip to content

Instantly share code, notes, and snippets.

@noqcks
Created September 3, 2014 20:13
Show Gist options
  • Save noqcks/fef3827ff190dbeaa9a1 to your computer and use it in GitHub Desktop.
Save noqcks/fef3827ff190dbeaa9a1 to your computer and use it in GitHub Desktop.
# Save this file to your computer so you can run it
# via the command line (Terminal) like so:
# $ ruby shakil_the_dog.rb
#
# Your method should wait for user input, which corresponds
# to you saying something to your dog (named Shakil).
# You'll probably want to write other methods, but this
# encapsulates the core dog logic
def shakil_the_dog
print "Say something to shakil: "
input = gets.chomp
unless input == "go away"
if case
when input == "woof"
puts "WOOF WOOF WOOF"
when input == "shakil stop" || input == "Shakil STOP!"
puts "shakil is silent"
when input == "meow"
puts "woof woof woof woof woof"
when input.match(/treat/)
puts "shakil waits patiently for a treat"
else
puts "woof"
end
end
end
end
# Run our method
shakil_the_dog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment