Created
May 7, 2014 08:19
-
-
Save radarek/b4fada966889263051b1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Bob | |
def hey(message) | |
if empty?(message) | |
"Fine. Be that way!" | |
elsif yelling?(message) | |
"Woah, chill out!" | |
elsif question?(message) | |
"Sure." | |
else | |
"Whatever." | |
end | |
end | |
private | |
def empty?(message) | |
message =~ /\A\s*\z/ | |
end | |
def yelling?(message) | |
message !~ /[a-z]/ && message =~ /[A-Z]/ | |
end | |
def question?(message) | |
message =~ /\?\z/ | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment