Skip to content

Instantly share code, notes, and snippets.

@coryschires
Created June 14, 2010 21:53
Show Gist options
  • Save coryschires/438373 to your computer and use it in GitHub Desktop.
Save coryschires/438373 to your computer and use it in GitHub Desktop.
ask helper for rake tasks
# 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