Class: Kontena::LightPrompt::Menu
- Inherits:
-
Object
- Object
- Kontena::LightPrompt::Menu
show all
- Defined in:
- lib/kontena/light_prompt.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Menu
Returns a new instance of Menu.
14
15
16
17
|
# File 'lib/kontena/light_prompt.rb', line 14
def initialize
@choices = []
@calls = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
35
36
37
|
# File 'lib/kontena/light_prompt.rb', line 35
def method_missing(meth, *args)
calls[meth] = args
end
|
Instance Attribute Details
#calls ⇒ Object
Returns the value of attribute calls.
12
13
14
|
# File 'lib/kontena/light_prompt.rb', line 12
def calls
@calls
end
|
#choices ⇒ Object
Returns the value of attribute choices.
12
13
14
|
# File 'lib/kontena/light_prompt.rb', line 12
def choices
@choices
end
|
Instance Method Details
#add_quit_choice ⇒ Object
23
24
25
|
# File 'lib/kontena/light_prompt.rb', line 23
def add_quit_choice
choice('(done)', :done)
end
|
#choice(text, label) ⇒ Object
19
20
21
|
# File 'lib/kontena/light_prompt.rb', line 19
def choice(text, label)
choices << [text, label]
end
|
#remove_choice(value) ⇒ Object
27
28
29
|
# File 'lib/kontena/light_prompt.rb', line 27
def remove_choice(value)
choices.reject! { |c| c.last == value }
end
|
#remove_choices(values) ⇒ Object
31
32
33
|
# File 'lib/kontena/light_prompt.rb', line 31
def remove_choices(values)
values.each { |v| remove_choice(v) }
end
|
#respond_to_missing?(meth, privates = false) ⇒ Boolean
39
40
41
|
# File 'lib/kontena/light_prompt.rb', line 39
def respond_to_missing?(meth, privates = false)
prompt.respond_to?(meth, privates)
end
|