-
-
Save 0x0dea/781130fc0bcddc16e177 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
print "Wanted to see if you were here today! yes/no? " | |
def handle_yes | |
puts "sweet! What time is good for you?" | |
time = gets.chomp | |
puts "Right on, I'll see you at #{time}!!" | |
end | |
def handle_no | |
puts "Sad. Next week it is!" | |
end | |
def handle_maybe | |
puts "Maybe, eh? Just let me know when is good for you!" | |
end | |
def handle_quit | |
puts "Goodbye" | |
end | |
matchers = { | |
yes: %w[YES Y], | |
no: %w[NO N], | |
maybe: %w[MAYBE], | |
quit: %w[Q QUIT EXIT] | |
} | |
while input = gets.chomp.upcase | |
if match = matchers.find { |_, matches| matches.include? input } | |
break send "handle_#{match.first}" | |
end | |
puts "That does not compute! Try again: yes/no? " | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment