Class: Blender::ScheduledJob
- Inherits:
-
Object
- Object
- Blender::ScheduledJob
- Defined in:
- lib/blender/scheduled_job.rb
Overview
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
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#schedule ⇒ Object
readonly
Returns the value of attribute schedule.
Instance Method Summary collapse
-
#blender_file(file) ⇒ Object
set the path of the file holding blender job.
-
#cron(line) ⇒ Object
set the job inteval via cron syntax.
-
#every(interval) ⇒ Object
set the job inteval after every specified seconds to rufus scheduler.
-
#initialize(name) ⇒ ScheduledJob
constructor
create a new instance.
-
#run ⇒ Object
invoke a blender run based on the
blender_file.
Constructor Details
#initialize(name) ⇒ ScheduledJob
create a new instance
30 31 32 33 |
# File 'lib/blender/scheduled_job.rb', line 30 def initialize(name) @name = name @file = name end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
27 28 29 |
# File 'lib/blender/scheduled_job.rb', line 27 def file @file end |
#schedule ⇒ Object (readonly)
Returns the value of attribute schedule.
27 28 29 |
# File 'lib/blender/scheduled_job.rb', line 27 def schedule @schedule end |
Instance Method Details
#blender_file(file) ⇒ Object
set the path of the file holding blender job
38 39 40 |
# File 'lib/blender/scheduled_job.rb', line 38 def blender_file(file) @file = file end |
#cron(line) ⇒ Object
set the job inteval via cron syntax. The value is passed as it is to rufus scheduler.
46 47 48 |
# File 'lib/blender/scheduled_job.rb', line 46 def cron(line) @schedule = [ __method__, line] end |
#every(interval) ⇒ Object
set the job inteval after every specified seconds to rufus scheduler.
54 55 56 |
# File 'lib/blender/scheduled_job.rb', line 54 def every(interval) @schedule = [ __method__, interval] end |
#run ⇒ Object
invoke a blender run based on the blender_file
59 60 61 62 63 64 |
# 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 |