Class: Potty::Mouth::Prompt::Confirm
- 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:, default: false) ⇒ Confirm
constructor
A new instance of Confirm.
Methods inherited from Base
Methods inherited from View
#activate, #deactivate, #layout_widgets, #on_activate, #on_deactivate, #render, #spacing, #tick
Constructor Details
#initialize(app, prompt:, default: false) ⇒ Confirm
Returns a new instance of Confirm.
149 150 151 152 153 154 |
# File 'lib/potty/mouth.rb', line 149 def initialize(app, prompt:, default: false) @prompt = prompt @default = default @result = nil super(app) end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
147 148 149 |
# File 'lib/potty/mouth.rb', line 147 def result @result end |
Instance Method Details
#build_layout ⇒ Object
156 157 158 159 |
# File 'lib/potty/mouth.rb', line 156 def build_layout hint = @default ? '[Y/n]' : '[y/N]' @widgets = [Potty::Widgets::Label.new(app, text: "#{@prompt} #{hint}", color: :info)] end |
#handle_escape ⇒ Object
170 171 172 |
# File 'lib/potty/mouth.rb', line 170 def handle_escape finish(@default) end |