Class: Fatty::AlertSession
- Defined in:
- lib/fatty/session/alert_session.rb
Overview
A pinned, non-interactive overlay session responsible for rendering alerts.
Instance Attribute Summary collapse
-
#current ⇒ Object
readonly
Returns the value of attribute current.
Attributes inherited from Session
#counter, #id, #keymap, #terminal
Instance Method Summary collapse
-
#initialize(id: nil) ⇒ AlertSession
constructor
A new instance of AlertSession.
- #state ⇒ Object
-
#update(command) ⇒ Object
Session Protocol.
- #view ⇒ Object
Methods inherited from Session
#close, #handle_resize, #init, #persist!, #renderer, #screen, #tick
Methods included from Actionable
Constructor Details
#initialize(id: nil) ⇒ AlertSession
Returns a new instance of AlertSession.
8 9 10 11 |
# File 'lib/fatty/session/alert_session.rb', line 8 def initialize(id: nil) super @current = nil end |
Instance Attribute Details
#current ⇒ Object (readonly)
Returns the value of attribute current.
6 7 8 |
# File 'lib/fatty/session/alert_session.rb', line 6 def current @current end |
Instance Method Details
#state ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fatty/session/alert_session.rb', line 32 def state [ current&.text.dup.freeze, current&.role, current&.details, renderer.screen.alert_rect.row, renderer.screen.alert_rect.cols, renderer.theme_version ] end |
#update(command) ⇒ Object
Session Protocol
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fatty/session/alert_session.rb', line 17 def update(command) Fatty.debug("AlertSession#update: action: #{command.action} alert: #{command.payload[:alert].inspect}") case command.action when :show show_from_payload(command.payload[:alert] || command.payload) when :clear @current = nil unless @current&.sticky? end [] end |
#view ⇒ Object
28 29 30 |
# File 'lib/fatty/session/alert_session.rb', line 28 def view renderer.render_alert(self) end |