Class: InputLoop

Inherits:
Object show all
Defined in:
lib/helpers/lib/input_loop.rb

Constant Summary collapse

DEFAULT_HINT =
{ 'y' => 'Yes', 'n' => 'No' }.freeze

Instance Method Summary collapse

Instance Method Details

#gets(message, list = 'Yn', **hint) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/helpers/lib/input_loop.rb', line 4

def gets(message, list = 'Yn', **hint)
  default, list = build_list(list)
  keys_hint, hint = build_hint(list, hint)

  print("#{message} (#{hint}) #{keys_hint}")
  wait_valid_input(keys_hint, Set.new(list.map(&:downcase)), default)
end