Class: Whenever::WebJob

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::DateHelper
Defined in:
app/models/whenever/web_job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job, interval) ⇒ WebJob

Returns a new instance of WebJob.



8
9
10
11
# File 'app/models/whenever/web_job.rb', line 8

def initialize job, interval
  @job      = job
  @interval = interval
end

Instance Attribute Details

#intervalObject (readonly)

Returns the value of attribute interval.



6
7
8
# File 'app/models/whenever/web_job.rb', line 6

def interval
  @interval
end

#jobObject (readonly)

Returns the value of attribute job.



6
7
8
# File 'app/models/whenever/web_job.rb', line 6

def job
  @job
end

Instance Method Details

#commandObject



19
20
21
22
# File 'app/models/whenever/web_job.rb', line 19

def command
  replacements = @job.options.map{ |k, v| [":#{k}", v] }.to_h
  @job.template.gsub(/:\w+/, replacements)
end

#descriptionObject



13
14
15
16
17
# File 'app/models/whenever/web_job.rb', line 13

def description
  @job.options.fetch(:description) {
    @job.options[:task]
  }
end