Created
March 20, 2013 22:19
-
-
Save ichabodcole/5209060 to your computer and use it in GitHub Desktop.
Deaf Grandma
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 Grandma | |
def initialize | |
@message = ""; | |
end | |
def speak_to(message) | |
if message == "BYE" | |
good_bye | |
return true | |
end | |
if message == message.upcase | |
i_heard_you | |
else | |
speak_up | |
end | |
end | |
def speak_up | |
puts "HUH, speak up sonny!!" | |
start() | |
end | |
def i_heard_you | |
first_word = @message.split(" ").first | |
word_length = first_word.length | |
message = first_word.slice(1, word_length) | |
puts "#{message}? No, not since 1938." | |
start() | |
end | |
def good_bye | |
puts "Good bye sonny!" | |
end | |
def start | |
puts "Grandma is listening" | |
@message = gets.chomp() | |
speak_to @message | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment