Class: Cron::CronJob
- Inherits:
-
Object
- Object
- Cron::CronJob
- Defined in:
- lib/DrbDB/Cron.rb
Instance Method Summary collapse
-
#initialize(cron_id, cron, moditems_id, command, drbdb) ⇒ CronJob
constructor
A new instance of CronJob.
- #register ⇒ Object
- #to_s ⇒ Object
- #unregister ⇒ Object
Constructor Details
#initialize(cron_id, cron, moditems_id, command, drbdb) ⇒ CronJob
Returns a new instance of CronJob.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/DrbDB/Cron.rb', line 7 def initialize(cron_id,cron,moditems_id,command,drbdb) @cron_id=cron_id @cron=cron @moditems_id=moditems_id @command=command @drbdb=drbdb @scheduler=@drbdb.scheduler @job=nil end |
Instance Method Details
#register ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/DrbDB/Cron.rb', line 17 def register @job=@scheduler.cron(@cron) {|job| if @drbdb.moditem(@moditems_id) and b=@drbdb.moditem(@moditems_id).getBinding then @drbdb.einfo("running ##{@cron_id} @#{@cron} on #{@drbdb.moditem(@moditems_id)}") ret=eval(@command, b) end } self end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/DrbDB/Cron.rb', line 29 def to_s "CronJob ##{@cron_id}" end |
#unregister ⇒ Object
26 27 28 |
# File 'lib/DrbDB/Cron.rb', line 26 def unregister @job.unschedule if @job end |