Skip to content

Instantly share code, notes, and snippets.

@jmmastey
Created June 9, 2014 18:04
Show Gist options
  • Save jmmastey/7e7be6ba6ac1e14a6515 to your computer and use it in GitHub Desktop.
Save jmmastey/7e7be6ba6ac1e14a6515 to your computer and use it in GitHub Desktop.
class Bob
def hey(input)
if(input.empty? || input.strip.empty?)
'Fine. Be that way!'
elsif(upcase(input))
"Woah, chill out!"
elsif(question(input))
'Sure.'
else
'Whatever.'
end
end
def upcase(input)
upcase_count = 0
input.split('').each do |c|
return false if(!c.match(/[a-z]/).nil?)
if(c.match(/[A-Z]/))
upcase_count += 1
end
end
return false if upcase_count==0
true
end
def question(input)
input[-1 ... input.length] == '?'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment