class Ruboty::Cron::Job
Attributes
attributes[R]
thread[R]
Public Class Methods
new(attributes)
click to toggle source
# File lib/ruboty/cron/job.rb, line 6 def initialize(attributes) @attributes = attributes.stringify_keys end
Public Instance Methods
body()
click to toggle source
# File lib/ruboty/cron/job.rb, line 53 def body attributes["body"] end
description()
click to toggle source
# File lib/ruboty/cron/job.rb, line 41 def description %<%5s: (%s) "%s" %s> % [id, suspended? ? "suspended" : "active", schedule, body] end
id()
click to toggle source
# File lib/ruboty/cron/job.rb, line 45 def id attributes["id"] end
resume(robot)
click to toggle source
# File lib/ruboty/cron/job.rb, line 36 def resume(robot) start(robot) attributes.delete("suspended") if attributes.has_key?("suspended") end
schedule()
click to toggle source
# File lib/ruboty/cron/job.rb, line 49 def schedule attributes["schedule"] end
start(robot)
click to toggle source
# File lib/ruboty/cron/job.rb, line 10 def start(robot) @thread = Thread.new do Chrono::Trigger.new(schedule) do robot.receive( attributes.symbolize_keys.except( :id, :schedule, ), ) end.run end end
stop()
click to toggle source
# File lib/ruboty/cron/job.rb, line 27 def stop thread.kill end
suspend()
click to toggle source
# File lib/ruboty/cron/job.rb, line 31 def suspend stop attributes["suspended"] = true end
suspended?()
click to toggle source
# File lib/ruboty/cron/job.rb, line 57 def suspended? !!attributes["suspended"] end
to_hash()
click to toggle source
# File lib/ruboty/cron/job.rb, line 23 def to_hash attributes end