Created
August 15, 2013 21:16
-
-
Save stevencwarren/6244984 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(phrase) | |
phrase = Phrase.new({text: phrase}) | |
case | |
when phrase.empty? | |
'Fine. Be that way!' | |
when phrase.yelling? | |
'Woah, chill out!' | |
when phrase.question? | |
'Sure.' | |
else | |
"Whatever." | |
end | |
end | |
end | |
class Phrase | |
attr_accessor :text | |
def initialize(args) | |
@text = args[:text] | |
end | |
def yelling? | |
text.upcase == text | |
end | |
def question? | |
text.end_with? '?' | |
end | |
def empty? | |
text.strip.empty? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment