Method: Nehm::UI::Menu#choice
- Defined in:
- lib/nehm/menu.rb
#choice(index, desc, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/nehm/menu.rb', line 14 def choice(index, desc, &block) # Visual index - index that you see in menu # Select index - index than can be selected # For example, if you use ':added' index # In menu you see 'A', but you can select it by number # You receive a warning though visual_index = select_index = index if index == :inc visual_index = select_index = @inc_index.to_s @inc_index += 1 end if index == :added visual_index = 'A'.green select_index = @inc_index.to_s @inc_index += 1 end @choices[select_index] = block @items << "#{visual_index} #{desc}" end |