Class: CampfireBot::Event::Interval
- Inherits:
-
EventHandler
- Object
- EventHandler
- CampfireBot::Event::Interval
- Defined in:
- lib/event.rb
Instance Attribute Summary
Attributes inherited from EventHandler
#kind, #matcher, #method, #plugin
Instance Method Summary collapse
-
#initialize(*args) ⇒ Interval
constructor
A new instance of Interval.
- #match? ⇒ Boolean
- #run(msg, force = false) ⇒ Object
Methods inherited from EventHandler
Constructor Details
#initialize(*args) ⇒ Interval
Returns a new instance of Interval.
73 74 75 76 |
# File 'lib/event.rb', line 73 def initialize(*args) @last_run = ::Time.now super(*args) end |
Instance Method Details
#match? ⇒ Boolean
78 79 80 |
# File 'lib/event.rb', line 78 def match? @last_run < ::Time.now - @matcher end |
#run(msg, force = false) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/event.rb', line 82 def run(msg, force = false) if match? @last_run = ::Time.now Plugin.registered_plugins[@plugin].send(@method, msg) else false end end |