Class: Kontena::LightPrompt
- Inherits:
-
Object
- Object
- Kontena::LightPrompt
show all
- Extended by:
- Forwardable
- Defined in:
- lib/kontena/light_prompt.rb
Defined Under Namespace
Classes: Menu
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ LightPrompt
44
45
46
|
# File 'lib/kontena/light_prompt.rb', line 44
def initialize(options={})
@prompt = TTY::Prompt.new(options)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
95
96
97
|
# File 'lib/kontena/light_prompt.rb', line 95
def method_missing(meth, *args)
prompt.send(meth, *args)
end
|
Instance Attribute Details
#prompt ⇒ Object
Returns the value of attribute prompt.
7
8
9
|
# File 'lib/kontena/light_prompt.rb', line 7
def prompt
@prompt
end
|
Instance Method Details
#multi_select(*args) {|choice_collector| ... } ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/kontena/light_prompt.rb', line 64
def multi_select(*args, &block)
choice_collector = .new
yield choice_collector
choice_collector.add_quit_choice
selections = []
loop do
choice_collector.remove_choices(selections)
answer = prompt.enum_select(*args) do ||
choice_collector.calls.each do |meth, args|
if .respond_to?(meth)
.send(meth, *args)
end
end
choice_collector.choices.each do |choice|
.choice choice.first, choice.last
end
end
break if answer == :done
selections << answer
end
selections
end
|
#respond_to_missing?(meth, privates = false) ⇒ Boolean
99
100
101
|
# File 'lib/kontena/light_prompt.rb', line 99
def respond_to_missing?(meth, privates = false)
prompt.respond_to?(meth, privates)
end
|
#select(*args) {|choice_collector| ... } ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/kontena/light_prompt.rb', line 48
def select(*args, &block)
choice_collector = .new
yield choice_collector
prompt.enum_select(*args) do ||
choice_collector.calls.each do |meth, args|
if .respond_to?(meth)
.send(meth, *args)
end
end
choice_collector.choices.each do |choice|
.choice choice.first, choice.last
end
end
end
|