class Ke::Job

Attributes

opts[R]
reporter[R]
task[R]

Public Class Methods

new(task, reporter, opts = {}) click to toggle source
# File lib/ke/job.rb, line 5
def initialize(task, reporter, opts = {})
  @task = task
  @reporter = reporter
  @opts = opts

  @opts[:report_every] ||= if @task.respond_to?(:total_ticks)
    [1, [@task.total_ticks / 10, 100].min].max
  else
    1
  end
end

Public Instance Methods

run() { |self| ... } click to toggle source
# File lib/ke/job.rb, line 23
def run
  task.start
  reporter.print_start
  return_val = yield(self)
  task.complete
  reporter.print_complete
  return_val
end
tick() { || ... } click to toggle source
# File lib/ke/job.rb, line 17
def tick
  task.tick
  reporter.print_tick if task.tick_count % opts[:report_every] == 0
  yield
end