Sha256: 39953ba426732c2efe579077b6eb057109b4e0ff12d7169c58da08ec8678fb76

Contents?: true

Size: 553 Bytes

Versions: 2

Compression:

Stored size: 553 Bytes

Contents

require 'whenever/patches/job'

module Whenever
  class WebJob
    include ActionView::Helpers::DateHelper
    attr_reader :interval, :job

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

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

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

    def interval
      distance_of_time_in_words(@interval)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
whenever-web-0.0.4 app/models/whenever/web_job.rb
whenever-web-0.0.3 app/models/whenever/web_job.rb