Class: Terraformer::UserInput
- Inherits:
-
Object
- Object
- Terraformer::UserInput
- Defined in:
- lib/terraformer/user_input.rb
Constant Summary collapse
- MAX_ATTEMPTS =
10
Class Method Summary collapse
Class Method Details
.ask(message, success, failure) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/terraformer/user_input.rb', line 17 def ask(, success, failure) (0..MAX_ATTEMPTS).each do |i| puts "#{} [#{success}/#{failure}]" response = get_input if response.downcase == success.downcase || response == "" return true elsif response.downcase == failure.downcase puts "Exiting" raise UserInputError end end raise UserInputMaxAttemptsError end |
.get_input ⇒ Object
12 13 14 15 |
# File 'lib/terraformer/user_input.rb', line 12 def get_input response = gets response.chomp end |