Class: Prompt
- Inherits:
-
Object
- Object
- Prompt
- Defined in:
- lib/prompt.rb
Overview
Class for prompting in terminal
Instance Method Summary collapse
Instance Method Details
#ask(message, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/prompt.rb', line 7 def ask(, = {}) print "#{} " input = $stdin.gets.chomp # Print input if running under specs Utilities.rspec_running? && (puts input) # Check for required input check_input(, input) input end |
#mask(message, options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/prompt.rb', line 20 def mask(, = {}) # Use simple output for specs Utilities.rspec_running? && (ask(, ) && return) print "#{} " return unless $stdin.class.method_defined?(:noecho) pass = $stdin.noecho(&:gets).chomp # Check for required input check_input(, pass) puts pass end |