Method: HighLine::Menu#select

Defined in:
lib/highline/menu.rb

#select(highline_context, selection, details = nil) ⇒ nil, Object

This method processes the auto-completed user selection, based on the rules for this Menu object. If an action was provided for the selection, it will be executed as described in #choice.

Parameters:

  • highline_context (HighLine)

    a HighLine instance to be used as context.

  • selection (String, Integer)

    index or title of the selected menu item.

  • details (defaults to: nil)

    additional parameter to be passed when in shell mode.

Returns:

  • (nil, Object)

    if @nil_on_handled is set it returns nil, else it returns the action return value.



408
409
410
411
412
413
414
415
416
417
418
# File 'lib/highline/menu.rb', line 408

def select(highline_context, selection, details = nil)
  # add in any hidden menu commands
  items = all_items

  # Find the selected action.
  selected_item = find_item_from_selection(items, selection)

  # Run or return it.
  @highline = highline_context
  value_for_selected_item(selected_item, details)
end