Created
June 14, 2010 21:53
-
-
Save coryschires/438373 to your computer and use it in GitHub Desktop.
ask helper for rake tasks
This file contains 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
# helper method for asking questions in a rake task - returns true or false | |
def ask?(question) | |
puts question | |
respnose = STDIN.gets.chomp.downcase | |
%w[yes y yep true].include?(respnose) | |
end | |
# example usage | |
if ask?("Are you having a nice day?") | |
puts "Great!" | |
else | |
put "Oh no!" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment