Class: Whenever::Output::Cron
- Inherits:
-
Object
- Object
- Whenever::Output::Cron
- Defined in:
- lib/outputs/cron.rb
Instance Attribute Summary collapse
-
#task ⇒ Object
Returns the value of attribute task.
-
#time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(time = nil, task = nil, at = nil, hour_range = nil) ⇒ Cron
constructor
A new instance of Cron.
- #time_in_cron_syntax ⇒ Object
Constructor Details
#initialize(time = nil, task = nil, at = nil, hour_range = nil) ⇒ Cron
Returns a new instance of Cron.
8 9 10 11 12 13 |
# File 'lib/outputs/cron.rb', line 8 def initialize(time = nil, task = nil, at = nil, hour_range = nil) @time = time @task = task @at = at.is_a?(String) ? (Chronic.parse(at) || 0) : (at || 0) @hour_range = hour_range end |
Instance Attribute Details
#task ⇒ Object
Returns the value of attribute task.
6 7 8 |
# File 'lib/outputs/cron.rb', line 6 def task @task end |
#time ⇒ Object
Returns the value of attribute time.
6 7 8 |
# File 'lib/outputs/cron.rb', line 6 def time @time end |
Class Method Details
.enumerate(item) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/outputs/cron.rb', line 15 def self.enumerate(item) if item and item.is_a?(String) items = item.split(',') else items = item items = [items] unless items and items.respond_to?(:each) end items end |
.output(times, job) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/outputs/cron.rb', line 25 def self.output(times, job) enumerate(times).each do |time| enumerate(job.at).each do |at| out = new(time, job.output, at, job.hour_range) yield "#{out.time_in_cron_syntax} #{out.task}" end end end |
Instance Method Details
#time_in_cron_syntax ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/outputs/cron.rb', line 34 def time_in_cron_syntax case @time when Symbol then parse_symbol when String then parse_as_string else parse_time end end |