class SidekiqScheduler::JobPresenter

Attributes

name[R]

Public Class Methods

build_collection(schedule_hash) click to toggle source

Builds the presenter instances for the schedule hash

@param schedule_hash [Hash] with the redis schedule @return [Array<JobPresenter>] an array with the instances of presenters

# File lib/sidekiq-scheduler/job_presenter.rb, line 66
def self.build_collection(schedule_hash)
  schedule_hash ||= {}

  schedule_hash.sort.map do |name, job_spec|
    new(name, job_spec)
  end
end
new(name, attributes) click to toggle source
# File lib/sidekiq-scheduler/job_presenter.rb, line 14
def initialize(name, attributes)
  @name = name
  @attributes = attributes
end

Public Instance Methods

[](key) click to toggle source

Delegates the :[] method to the attributes’ hash

@return [String] with the value for that key

# File lib/sidekiq-scheduler/job_presenter.rb, line 54
def [](key)
  @attributes[key]
end
enabled?() click to toggle source
# File lib/sidekiq-scheduler/job_presenter.rb, line 58
def enabled?
  SidekiqScheduler::Scheduler.job_enabled?(@name)
end
interval() click to toggle source

Returns the interval for the job

@return [String] with the job’s interval

# File lib/sidekiq-scheduler/job_presenter.rb, line 40
def interval
  @attributes['cron'] || @attributes['interval'] || @attributes['every'] || @attributes['at'] || @attributes['in']
end
last_time() click to toggle source

Returns the last execution time for the job

@return [String] with the job’s last time

# File lib/sidekiq-scheduler/job_presenter.rb, line 31
def last_time
  execution_time = SidekiqScheduler::RedisManager.get_job_last_time(name)

  relative_time(Time.parse(execution_time)) if execution_time
end
next_time() click to toggle source

Returns the next time execution for the job

@return [String] with the job’s next time

# File lib/sidekiq-scheduler/job_presenter.rb, line 22
def next_time
  execution_time = SidekiqScheduler::RedisManager.get_job_next_time(name)

  relative_time(Time.parse(execution_time)) if execution_time
end
queue() click to toggle source

Returns the queue of the job

@return [String] with the job’s queue

# File lib/sidekiq-scheduler/job_presenter.rb, line 47
def queue
  @attributes.fetch('queue', 'default')
end