Class: CampfireBot::Event::EventHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/event.rb

Overview

This is an abstract base class for all event types, not to be used directly.

Direct Known Subclasses

Command, Interval, Message, Speaker, Time

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#kindObject (readonly)

Returns the value of attribute kind.



7
8
9
# File 'lib/event.rb', line 7

def kind
  @kind
end

#matcherObject (readonly)

Returns the value of attribute matcher.



7
8
9
# File 'lib/event.rb', line 7

def matcher
  @matcher
end

#methodObject (readonly)

Returns the value of attribute method.



7
8
9
# File 'lib/event.rb', line 7

def method
  @method
end

#pluginObject (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, filter_message(msg))
  else
    false
  end
end