Class: CampfireBot::Event::Interval

Inherits:
EventHandler show all
Defined in:
lib/event.rb

Instance Attribute Summary

Attributes inherited from EventHandler

#kind, #matcher, #method, #plugin

Instance Method Summary collapse

Methods inherited from EventHandler

handles

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

Returns:

  • (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