Skip to content

Instantly share code, notes, and snippets.

@ronan-mch
Created October 2, 2012 13:51
Show Gist options
  • Save ronan-mch/3819326 to your computer and use it in GitHub Desktop.
Save ronan-mch/3819326 to your computer and use it in GitHub Desktop.
Ruby code for getting confirms from user
def prompt(*args)
print(*args)
gets.chomp!
end
def confirm(*args)
answer = prompt(*args, "(Y/N)")
if (answer.downcase =~ /^y|^n/)
return answer =~ /y/ ? true : false
else
return confirm(*args)
end
end
really = confirm "Continue? "
puts really
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment