Skip to content

Instantly share code, notes, and snippets.

@0x0dea
Forked from anonymous/here?.rb
Created July 2, 2015 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0x0dea/781130fc0bcddc16e177 to your computer and use it in GitHub Desktop.
Save 0x0dea/781130fc0bcddc16e177 to your computer and use it in GitHub Desktop.
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