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