lib/rufus/scheduler.rb in rufus-scheduler-3.0.7 vs lib/rufus/scheduler.rb in rufus-scheduler-3.0.8

- old
+ new

@@ -36,11 +36,11 @@ require 'rufus/scheduler/util' require 'rufus/scheduler/jobs' require 'rufus/scheduler/cronline' require 'rufus/scheduler/job_array' - VERSION = '3.0.7' + VERSION = '3.0.8' # # A common error class for rufus-scheduler # class Error < StandardError; end @@ -163,10 +163,15 @@ def down? ! @started_at end + def up? + + !! @started_at + end + def paused? @paused end @@ -234,24 +239,24 @@ do_schedule(:cron, cronline, callable, opts, true, block) end def schedule(arg, callable=nil, opts={}, &block) - # TODO: eventually, spare one parse call + opts[:_t] = Scheduler.parse(arg, opts) - case Scheduler.parse(arg) + case opts[:_t] when CronLine then schedule_cron(arg, callable, opts, &block) when Time then schedule_at(arg, callable, opts, &block) else schedule_in(arg, callable, opts, &block) end end def repeat(arg, callable=nil, opts={}, &block) - # TODO: eventually, spare one parse call + opts[:_t] = Scheduler.parse(arg, opts) - case Scheduler.parse(arg) + case opts[:_t] when CronLine then schedule_cron(arg, callable, opts, &block) else schedule_every(arg, callable, opts, &block) end end @@ -610,11 +615,11 @@ return_job_instance ||= opts[:job] job_class = case job_type when :once - tt = Rufus::Scheduler.parse(t) - tt.is_a?(Time) ? AtJob : InJob + opts[:_t] ||= Rufus::Scheduler.parse(t, opts) + opts[:_t].is_a?(Time) ? AtJob : InJob when :every EveryJob when :interval IntervalJob when :cron