Class: Xronor::Job
- Inherits:
-
Object
- Object
- Xronor::Job
- Defined in:
- lib/xronor/job.rb
Constant Summary collapse
- DOM_INDEX =
2
- DOW_INDEX =
4
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#schedule ⇒ Object
readonly
Returns the value of attribute schedule.
Instance Method Summary collapse
- #cloud_watch_rule_name(prefix) ⇒ Object
- #cloud_watch_schedule ⇒ Object
-
#initialize(name, description, schedule, command) ⇒ Job
constructor
A new instance of Job.
Constructor Details
#initialize(name, description, schedule, command) ⇒ Job
6 7 8 9 10 11 |
# File 'lib/xronor/job.rb', line 6 def initialize(name, description, schedule, command) @name = name @description = description @schedule = schedule @command = command end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
13 14 15 |
# File 'lib/xronor/job.rb', line 13 def command @command end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
13 14 15 |
# File 'lib/xronor/job.rb', line 13 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/xronor/job.rb', line 13 def name @name end |
#schedule ⇒ Object (readonly)
Returns the value of attribute schedule.
13 14 15 |
# File 'lib/xronor/job.rb', line 13 def schedule @schedule end |
Instance Method Details
#cloud_watch_rule_name(prefix) ⇒ Object
34 35 36 |
# File 'lib/xronor/job.rb', line 34 def cloud_watch_rule_name(prefix) "#{prefix}#{@name}-#{hashcode}".gsub(/[^\.\-_A-Za-z0-9]/, "-").downcase end |
#cloud_watch_schedule ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/xronor/job.rb', line 15 def cloud_watch_schedule cron_fields = @schedule.split(" ") if cron_fields[DOM_INDEX] == "*" && cron_fields[DOW_INDEX] == "*" cron_fields[DOW_INDEX] = "?" else cron_fields[DOM_INDEX] = "?" if cron_fields[DOM_INDEX] == "*" if cron_fields[DOW_INDEX] == "*" cron_fields[DOW_INDEX] = "?" else cron_fields[DOW_INDEX] = cron_fields[DOW_INDEX].to_i + 1 end end cron_fields << "*" # Year "cron(#{cron_fields.join(" ")})" end |