class Blender::ScheduledJob
A scheduled job encapsulates a blender based job to be executed at certain interval. Job
is specified as a file path, where the file contains job written in blender's DSL. Job
interval can be specified either via cron
or every
method
Blender::Timer
object uses ScheduledJob
and to execute the job and Rufus::Scheduler to schedule it
Attributes
Public Class Methods
create a new instance @param name [String] name of the job
# File lib/blender/scheduled_job.rb, line 30 def initialize(name) @name = name @file = name end
Public Instance Methods
set the path of the file holding blender job
@param file [String] path of the blender file
# File lib/blender/scheduled_job.rb, line 38 def blender_file(file) @file = file end
set the job inteval via cron syntax. The value is passed as it is to rufus scheduler.
@param line [String] job interval in cron syntax e.g (*/5 * * * *)
# File lib/blender/scheduled_job.rb, line 46 def cron(line) @schedule = [ __method__, line] end
set the job inteval after every specified seconds to rufus scheduler.
@param interval [Fixnum] job interval in seconds
# File lib/blender/scheduled_job.rb, line 54 def every(interval) @schedule = [ __method__, interval] end
invoke a blender run based on the blender_file
# File lib/blender/scheduled_job.rb, line 59 def run des = File.read(file) Blender.blend(file) do |sch| sch.instance_eval(des, __FILE__, __LINE__) end end