Skip to content

Instantly share code, notes, and snippets.

@jkirkpatrick24
Created July 19, 2016 23:43
Show Gist options
  • Save jkirkpatrick24/0be5988041be968a4e82528bf3c8f54e to your computer and use it in GitHub Desktop.
Save jkirkpatrick24/0be5988041be968a4e82528bf3c8f54e to your computer and use it in GitHub Desktop.
Chat with Shakil!
def talk
while true
print "Talk to shakil "
input = gets.strip
return input if input.length > 0
puts "Invalid input"
end
end
def conversation(talk)
case talk
when 'woof'
output = 'WOOF WOOF WOOF'
when 'meow'
output = 'woof woof woof woof woof'
when /shakil down/i
output = "shakil goes quiet for a few precious seconds"
when /treat/
output = 'shakil stares at you just wanting a treat'
when 'go away'
return false
else
output = 'shak doesnt understand'
end
end
def shakil_the_dog
while true
input = talk
output = conversation(input)
break unless output
puts output
end
puts 'shakil left'
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