Class: Potty::Mouth::Prompt::Choose
- Defined in:
- lib/potty/mouth.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Attributes inherited from View
Instance Method Summary collapse
- #build_layout ⇒ Object
- #handle_escape ⇒ Object
- #handle_key(ch) ⇒ Object
-
#initialize(app, prompt:, options:) ⇒ Choose
constructor
A new instance of Choose.
Methods inherited from Base
Methods inherited from View
#activate, #deactivate, #layout_widgets, #on_activate, #on_deactivate, #render, #spacing, #tick
Constructor Details
#initialize(app, prompt:, options:) ⇒ Choose
Returns a new instance of Choose.
186 187 188 189 190 191 |
# File 'lib/potty/mouth.rb', line 186 def initialize(app, prompt:, options:) @prompt = prompt @options = @result = nil super(app) end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
184 185 186 |
# File 'lib/potty/mouth.rb', line 184 def result @result end |
Instance Method Details
#build_layout ⇒ Object
193 194 195 196 197 198 |
# File 'lib/potty/mouth.rb', line 193 def build_layout opts = @options.map { |o| o.is_a?(Hash) ? o : { value: o, label: o.to_s } } @radio = Potty::Widgets::RadioGroup.new(app, options: opts) @widgets = [Potty::Widgets::Label.new(app, text: @prompt, color: :info), @radio] @radio.focus end |
#handle_escape ⇒ Object
209 210 211 212 213 |
# File 'lib/potty/mouth.rb', line 209 def handle_escape @result = nil app.quit true end |