Class: Fatty::Terminal::PopupOwner
- Inherits:
-
Object
- Object
- Fatty::Terminal::PopupOwner
- Defined in:
- lib/fatty/terminal/popup_owner.rb
Instance Attribute Summary collapse
-
#on_cancel ⇒ Object
readonly
Returns the value of attribute on_cancel.
-
#on_change ⇒ Object
readonly
Returns the value of attribute on_change.
-
#on_result ⇒ Object
readonly
Returns the value of attribute on_result.
Instance Method Summary collapse
-
#initialize(on_result: nil, on_cancel: nil, on_change: nil) ⇒ PopupOwner
constructor
A new instance of PopupOwner.
- #update(command) ⇒ Object
Constructor Details
#initialize(on_result: nil, on_cancel: nil, on_change: nil) ⇒ PopupOwner
Returns a new instance of PopupOwner.
8 9 10 11 12 |
# File 'lib/fatty/terminal/popup_owner.rb', line 8 def initialize(on_result: nil, on_cancel: nil, on_change: nil) @on_result = on_result @on_cancel = on_cancel @on_change = on_change end |
Instance Attribute Details
#on_cancel ⇒ Object (readonly)
Returns the value of attribute on_cancel.
6 7 8 |
# File 'lib/fatty/terminal/popup_owner.rb', line 6 def on_cancel @on_cancel end |
#on_change ⇒ Object (readonly)
Returns the value of attribute on_change.
6 7 8 |
# File 'lib/fatty/terminal/popup_owner.rb', line 6 def on_change @on_change end |
#on_result ⇒ Object (readonly)
Returns the value of attribute on_result.
6 7 8 |
# File 'lib/fatty/terminal/popup_owner.rb', line 6 def on_result @on_result end |
Instance Method Details
#update(command) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fatty/terminal/popup_owner.rb', line 14 def update(command) result = case command.action when :popup_result, :prompt_result on_result&.call(command.payload) when :popup_cancelled, :prompt_cancelled on_cancel&.call when :popup_changed on_change&.call(command.payload) end Command.normalize_list(result) end |