Class: Clockworkd::Event
- Inherits:
-
Object
- Object
- Clockworkd::Event
- Defined in:
- lib/clockworkd/event.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#cron_time ⇒ Object
Returns the value of attribute cron_time.
-
#cronline ⇒ Object
Returns the value of attribute cronline.
-
#job ⇒ Object
Returns the value of attribute job.
-
#next_time ⇒ Object
Returns the value of attribute next_time.
Instance Method Summary collapse
-
#initialize(job, block, cronline) ⇒ Event
constructor
A new instance of Event.
- #run(t) ⇒ Object
- #time?(t) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
3 4 5 |
# File 'lib/clockworkd/event.rb', line 3 def block @block end |
#cron_time ⇒ Object
Returns the value of attribute cron_time.
3 4 5 |
# File 'lib/clockworkd/event.rb', line 3 def cron_time @cron_time end |
#cronline ⇒ Object
Returns the value of attribute cronline.
3 4 5 |
# File 'lib/clockworkd/event.rb', line 3 def cronline @cronline end |
#job ⇒ Object
Returns the value of attribute job.
3 4 5 |
# File 'lib/clockworkd/event.rb', line 3 def job @job end |
#next_time ⇒ Object
Returns the value of attribute next_time.
3 4 5 |
# File 'lib/clockworkd/event.rb', line 3 def next_time @next_time end |
Instance Method Details
#run(t) ⇒ Object
25 26 27 28 29 |
# File 'lib/clockworkd/event.rb', line 25 def run(t) eval(@block) rescue Exception => e raise e end |
#time?(t) ⇒ Boolean
17 18 19 20 21 22 23 |
# File 'lib/clockworkd/event.rb', line 17 def time?(t) if (t.to_i - @next_time.to_i) > 0 @next_time = @cron_time.next_time return true end false end |
#to_s ⇒ Object
13 14 15 |
# File 'lib/clockworkd/event.rb', line 13 def to_s @job = job end |