Class: Whenever::JobSequence
- Inherits:
-
Array
- Object
- Array
- Whenever::JobSequence
- Defined in:
- lib/whenever/job_sequence.rb
Instance Attribute Summary collapse
-
#dependent ⇒ Object
writeonly
Sets the attribute dependent.
Instance Method Summary collapse
-
#initialize(options = {}, size = 0, obj = nil) ⇒ JobSequence
constructor
A new instance of JobSequence.
- #to_single_job ⇒ Object
Constructor Details
#initialize(options = {}, size = 0, obj = nil) ⇒ JobSequence
Returns a new instance of JobSequence.
5 6 7 8 9 10 |
# File 'lib/whenever/job_sequence.rb', line 5 def initialize(={}, size=0, obj=nil) super(size, obj) @options = @dependent = .fetch(:dependent, true) end |
Instance Attribute Details
#dependent=(value) ⇒ Object (writeonly)
Sets the attribute dependent
3 4 5 |
# File 'lib/whenever/job_sequence.rb', line 3 def dependent=(value) @dependent = value end |
Instance Method Details
#to_single_job ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/whenever/job_sequence.rb', line 12 def to_single_job = @options.dup default_redirection = .delete(:output) concatenation = @dependent ? " && " : "; " tasks_with_redirection = map do |t| if redirection = t.output_redirection.nil? || t.output_redirection == :not_set ? default_redirection : t.output_redirection t.output + " " + Output::Cron::OutputRedirection.new(redirection).to_s else t.output end end single_task = tasks_with_redirection.join(concatenation) Job::Default.new(.merge(:task => single_task)) end |