summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbinoam P. Marques Jr <abinoam@gmail.com>2017-07-01 22:12:47 -0300
committerAbinoam P. Marques Jr <abinoam@gmail.com>2017-07-01 22:12:47 -0300
commit456e21c03daa3b45a745b1c044b43076192249fd (patch)
tree12ce219eb94e97a1dae110aecf923a53b3047d39
parent67425093c2bfc9ef9964081b6c4192c3118c52ec (diff)
downloadhighline-456e21c03daa3b45a745b1c044b43076192249fd.tar.gz
Fix menu indexing by letter
-rw-r--r--lib/highline/menu.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/highline/menu.rb b/lib/highline/menu.rb
index a743c4d..d9a2b6e 100644
--- a/lib/highline/menu.rb
+++ b/lib/highline/menu.rb
@@ -423,8 +423,10 @@ class HighLine
def get_item_by_letter(items, selection)
item = items.find { |i| i.name == selection }
return item if item
- l_index = "`" # character before the letter "a"
- index = items.map { l_index.succ!.to_s }.index(selection)
+
+ # 97 is the "a" letter at ascii table
+ # Ex: For "a" it will return 0, and for "c" it will return 2
+ index = selection.ord - 97
items[index]
end