lib/tty/prompt.rb
# Invoke a list type of prompt
#
# @example
#   prompt = TTY::Prompt.new
#   editors = %w(emacs nano vim)
#   prompt.invoke_select(EnumList, "Select editor: ", editors)
#
# @return [String]
#
# @api public
Invoke a list type of prompt
Invoke a list type of prompt
def invoke_select(object, question, *args, &block)
      options = Utils.extract_options!(args)
      choices = if block
                  []
                elsif args.empty?
                  possible = options.dup
                  options = {}
                  possible
                elsif args.size == 1 && args[0].is_a?(Hash)
                  Utils.extract_options!(args)
                else
                  args.flatten
                end
      list = object.new(self, options)
      list.(question, choices, &block)
    end
def invoke_select ( object , question , * args , & block ) options = Utils . extract_options! ( args ) choices = if block [ ] elsif args . empty? possible = options . dup options = { } possible elsif args . size == 1 && args [ 0 ] . is_a? ( Hash ) Utils . extract_options! ( args ) else args . flatten end list = object . new ( self , options ) list . ( question , choices , & block ) end
Invoke a list type of prompt
Invoke a list type of prompt
None
String
object
question
args
block
example
prompt = TTY::Prompt.new editors = %w(emacs nano vim) prompt.invoke_select(EnumList, "Select editor: ", editors)
prompt = TTY :: Prompt . new editors = %w ( emacs nano vim ) prompt . invoke_select ( EnumList " Select editor : " editors )
api
None