Class: Qless::ClientJobs

Inherits:
Object
  • Object
show all
Defined in:
lib/qless.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ ClientJobs

Returns a new instance of ClientJobs.



44
45
46
# File 'lib/qless.rb', line 44

def initialize(client)
  @client = client
end

Instance Method Details

#[](id) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/qless.rb', line 72

def [](id)
  results = @client._get.call([], [id])
  if results.nil?
    results = @client._recur.call([], ['get', id])
    if results.nil?
      return nil
    end
    return RecurringJob.new(@client, JSON.parse(results))
  end
  Job.new(@client, JSON.parse(results))
end

#complete(offset = 0, count = 25) ⇒ Object



48
49
50
# File 'lib/qless.rb', line 48

def complete(offset=0, count=25)
  @client._jobs.call([], ['complete', offset, count])
end

#failed(t = nil, start = 0, limit = 25) ⇒ Object



62
63
64
65
66
67
68
69
70
# File 'lib/qless.rb', line 62

def failed(t=nil, start=0, limit=25)
  if not t
    JSON.parse(@client._failed.call([], []))
  else
    results = JSON.parse(@client._failed.call([], [t, start, limit]))
    results['jobs'] = results['jobs'].map { |j| Job.new(@client, j) }
    results
  end
end

#tagged(tag, offset = 0, count = 25) ⇒ Object



58
59
60
# File 'lib/qless.rb', line 58

def tagged(tag, offset=0, count=25)
  JSON.parse(@client._tag.call([], ['get', tag, offset, count]))
end

#trackedObject



52
53
54
55
56
# File 'lib/qless.rb', line 52

def tracked
  results = JSON.parse(@client._track.call([], []))
  results['jobs'] = results['jobs'].map { |j| Job.new(@client, j) }
  results
end