class HighLine::Menu

def get_item_by_letter(items, selection)

Parameters:
  • selection (String) -- menu's title/header/name
def get_item_by_letter(items, selection)
  item = items.find { |i| i.name == selection }
  return item if item
  # 97 is the "a" letter at ascii table
  # Ex: For "a" it will return 0, and for "c" it will return 2
  index = selection.downcase.ord - 97
  items[index]
end