Class: Fatty::Terminal::PopupOwner

Inherits:
Object
  • Object
show all
Defined in:
lib/fatty/terminal/popup_owner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(on_result: nil, on_cancel: nil) ⇒ PopupOwner

Returns a new instance of PopupOwner.



8
9
10
11
# File 'lib/fatty/terminal/popup_owner.rb', line 8

def initialize(on_result: nil, on_cancel: nil)
  @on_result = on_result
  @on_cancel = on_cancel
end

Instance Attribute Details

#on_cancelObject (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_resultObject (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(msg) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fatty/terminal/popup_owner.rb', line 13

def update(msg)
  _cmd, name, payload = msg

  case name
  when :popup_result, :prompt_result
    on_result&.call(payload)
  when :popup_cancelled, :prompt_cancelled
    on_cancel&.call
  end
  []
end