Skip to content

Instantly share code, notes, and snippets.

@mileszs
Created November 14, 2013 00:52
Show Gist options
  • Save mileszs/7459360 to your computer and use it in GitHub Desktop.
Save mileszs/7459360 to your computer and use it in GitHub Desktop.
class Bob
def hey(input)
input = Input.new(input)
if input.blank?
'Fine. Be that way.'
elsif input.shouting?
'Woah, chill out!'
elsif input.question?
'Sure.'
else
'Whatever.'
end
end
end
class Input
attr_accessor :string
def initialize(value)
self.string = value
end
def blank?
string.nil? || string.strip == ''
end
def shouting?
!blank? && string !~ /[a-z]/
end
def question?
string =~ /\?$/
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment