blob: 78594cf61ff715b8d2efef794474292a13b16033 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# encoding: utf-8
class HighLine
class Menu < Question
# Represents an Item of a HighLine::Menu.
#
class Item
attr_reader :name, :text, :help, :action
#
# @param name [String] The name that is matched against the user input
# @param attributes [Hash] options Hash to tailor menu item to your needs
# @option attributes text: [String] The text that displays for that
# choice (defaults to name)
# @option attributes help: [String] help/hint string to be displayed.
# @option attributes action: [Block] a block that gets called when choice
# is selected
#
def initialize(name, attributes)
@name = name
@text = attributes[:text] || @name
@help = attributes[:help]
@action = attributes[:action]
end
def item_help
return {} unless help
{ name.to_s.downcase => help }
end
end
end
end
|