Created
June 9, 2014 18:04
-
-
Save jmmastey/7e7be6ba6ac1e14a6515 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(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