Skip to content

Instantly share code, notes, and snippets.

@xeqi
Created August 14, 2013 01:45
Show Gist options
  • Save xeqi/6227351 to your computer and use it in GitHub Desktop.
Save xeqi/6227351 to your computer and use it in GitHub Desktop.
bob exercism
class Bob
def hey(message)
behaviors = {
-> {message.nil? || message.strip.empty?} => 'Fine. Be that way!',
-> {message.upcase == message} => 'Woah, chill out!',
-> {message[-1].chr == '?'} => 'Sure.'
}
behaviors.fetch(behaviors.keys.find(&:call), "Whatever.")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment