Sha256: 4454035d27180b7be911eb98ebb3255879a75842f8c938b88e107f20d487c9a8
Contents?: true
Size: 722 Bytes
Versions: 1
Compression:
Stored size: 722 Bytes
Contents
module Terraformer class UserInputError < RuntimeError end class UserInputMaxAttemptsError < RuntimeError end class UserInput MAX_ATTEMPTS = 10 class << self def get_input response = gets response.chomp end def ask(message, success, failure) (0..MAX_ATTEMPTS).each do |i| puts "#{message} [#{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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
terraform-exporter-0.0.2 | lib/terraformer/user_input.rb |