Class: CampfireBot::Event::EventHandler
- Inherits:
-
Object
- Object
- CampfireBot::Event::EventHandler
- Defined in:
- lib/event.rb
Overview
This is an abstract base class for all event types, not to be used directly.
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#matcher ⇒ Object
readonly
Returns the value of attribute matcher.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#plugin ⇒ Object
readonly
Returns the value of attribute plugin.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(matcher, plugin_name, method_name) ⇒ EventHandler
constructor
A new instance of EventHandler.
- #run(msg, force = false) ⇒ Object
Constructor Details
#initialize(matcher, plugin_name, method_name) ⇒ EventHandler
Returns a new instance of EventHandler.
13 14 15 16 17 |
# File 'lib/event.rb', line 13 def initialize(matcher, plugin_name, method_name) @matcher = matcher @plugin = plugin_name @method = method_name end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
7 8 9 |
# File 'lib/event.rb', line 7 def kind @kind end |
#matcher ⇒ Object (readonly)
Returns the value of attribute matcher.
7 8 9 |
# File 'lib/event.rb', line 7 def matcher @matcher end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
7 8 9 |
# File 'lib/event.rb', line 7 def method @method end |
#plugin ⇒ Object (readonly)
Returns the value of attribute plugin.
7 8 9 |
# File 'lib/event.rb', line 7 def plugin @plugin end |
Class Method Details
.handles(event_type) ⇒ Object
9 10 11 |
# File 'lib/event.rb', line 9 def self.handles(event_type) @kind = event_type end |
Instance Method Details
#run(msg, force = false) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/event.rb', line 19 def run(msg, force = false) if force || match?(msg) Plugin.registered_plugins[@plugin].send(@method, (msg)) else false end end |