Skip to content

Instantly share code, notes, and snippets.

@stevencwarren
Created August 15, 2013 21:16
Show Gist options
  • Save stevencwarren/6244984 to your computer and use it in GitHub Desktop.
Save stevencwarren/6244984 to your computer and use it in GitHub Desktop.
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