Method: App42::Base::Util#input

Defined in:
lib/app42/base/util.rb

#input(message, choices, indexed = true) ⇒ Object

Reading input from user

Parameters:

  • message
  • choices
  • indexed (defaults to: true)

Returns:

  • input string



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/app42/base/util.rb', line 23

def input message, choices, indexed = true
  if choices.empty?
    ans = ask Paint["#{message}", :cyan]
  else
    list = choices.compact unless choices.empty? 
    ans = ask Paint["#{message}", :cyan],
      :choices => list,
      :default => list[0],
      :indexed => indexed
  end
  print_new_line
  return ans    
end