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

file[R]
schedule[R]

Public Class Methods

new(name) click to toggle source

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

blender_file(file) click to toggle source

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
cron(line) click to toggle source

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
every(interval) click to toggle source

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
run() click to toggle source

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