Class: Brut::TUI::Events::BaseEvent
- Inherits:
-
Object
- Object
- Brut::TUI::Events::BaseEvent
- Defined in:
- lib/brut/tui/events/base_event.rb
Overview
Base class for all events the TUI will manage. You can create custom events but they must subclass this one (or conform to its interface, which may change).
Direct Known Subclasses
EventLoopStarted, Exception, Tick, Script::Events::CommandStdOut, Script::Events::ExecutingCommand, Script::Events::Message, Script::Events::PhaseStarted, Script::Events::ScriptCompleted, Script::Events::ScriptStarted, Script::Events::StepStarted
Class Method Summary collapse
-
.handler_method_name ⇒ Object
Returns the method name that subscribers must implement to handle this event.
Instance Method Summary collapse
-
#deconstruct_keys(keys = nil) ⇒ Object
Provides
class_nameandhandler_method_name. -
#drain_then_exit? ⇒ Boolean
True if this event indicates the TUI should exit, but draining any outstanding events is OK first.
-
#exit? ⇒ Boolean
True if the reception of this event indicates the app should exit right now, potentially leaving un-handled events.
Class Method Details
.handler_method_name ⇒ Object
Returns the method name that subscribers must implement to handle this event.
By default, this is based on the underscorized simple class name (name without module namespacing)
suffixed with on_.
9 10 11 12 13 14 |
# File 'lib/brut/tui/events/base_event.rb', line 9 def self.handler_method_name @handler_method_name ||= begin simple_class_name = RichString.new(self.name.split("::").last) "on_#{simple_class_name.underscorized}" end end |
Instance Method Details
#deconstruct_keys(keys = nil) ⇒ Object
Provides class_name and handler_method_name. Subclasses are expected to call this
so they are included with their keys.
18 19 20 |
# File 'lib/brut/tui/events/base_event.rb', line 18 def deconstruct_keys(keys=nil) { class_name: self.class.name, handler_method_name: self.class.handler_method_name } end |
#drain_then_exit? ⇒ Boolean
True if this event indicates the TUI should exit, but draining any outstanding events is OK first.
28 |
# File 'lib/brut/tui/events/base_event.rb', line 28 def drain_then_exit? = false |
#exit? ⇒ Boolean
True if the reception of this event indicates the app should exit right now, potentially leaving un-handled events.
24 |
# File 'lib/brut/tui/events/base_event.rb', line 24 def exit? = false |