Class: Chatroid::Timer::Event
- Inherits:
-
Object
- Object
- Chatroid::Timer::Event
- Defined in:
- lib/chatroid/timer/event.rb
Constant Summary collapse
- UNITS =
‘every` is a Hash object which may have following keys: :sec :min :hour
‘block` will be executed at times specified by `every`
Example: “Hello, world!” will be printed at 14:00 and 14:30 every day event = Event.new(:hour => 14, :min => [0, 30], :sec => 0) do
foo
end
loop do
event.call sleep 1
end
[ :sec, :min, :hour, :day, :wday, :month, ].freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(every, &block) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(every, &block) ⇒ Event
Returns a new instance of Event.
30 31 32 33 |
# File 'lib/chatroid/timer/event.rb', line 30 def initialize(every, &block) @every = every @block = block end |
Instance Method Details
#call ⇒ Object
35 36 37 |
# File 'lib/chatroid/timer/event.rb', line 35 def call @block.call if available? end |