def do_schedule(job_type, t, callable, opts, return_job_instance, block)
fail NotRunningError.new(
'cannot schedule, scheduler is down or shutting down'
) if @started_at.nil?
callable, opts = nil, callable if callable.is_a?(Hash)
opts = opts.dup unless opts.has_key?(:_t)
return_job_instance ||= opts[:job]
job_class =
case job_type
when :once
opts[:_t] ||= Rufus::Scheduler.parse(t, opts)
opts[:_t].is_a?(Numeric) ? InJob : AtJob
when :every
EveryJob
when :interval
IntervalJob
when :cron
CronJob
end
job = job_class.new(self, t, opts, block || callable)
fail ArgumentError.new(
"job frequency (#{job.frequency}) is higher than " +
"scheduler frequency (#{@frequency})"
) if job.respond_to?(:frequency) && job.frequency < @frequency
@jobs.push(job)
return_job_instance ? job : job.job_id
end