class Qless::ClientJobs
A class for interacting with jobs. Not meant to be instantiated directly, it's accessed through Client#jobs
Public Class Methods
new(client)
click to toggle source
# File lib/qless.rb, line 53 def initialize(client) @client = client end
Public Instance Methods
[](id)
click to toggle source
# File lib/qless.rb, line 84 def [](id) get(id) end
complete(offset = 0, count = 25)
click to toggle source
# File lib/qless.rb, line 57 def complete(offset = 0, count = 25) @client.call('jobs', 'complete', offset, count) end
failed(t = nil, start = 0, limit = 25)
click to toggle source
# File lib/qless.rb, line 74 def failed(t = nil, start = 0, limit = 25) if !t return JSON.parse(@client.call('failed')) else results = JSON.parse(@client.call('failed', t, start, limit)) results['jobs'] = multiget(*results['jobs']) results end end
get(jid)
click to toggle source
# File lib/qless.rb, line 88 def get(jid) results = @client.call('get', jid) if results.nil? results = @client.call('recur.get', jid) return nil if results.nil? return RecurringJob.new(@client, JSON.parse(results)) end Job.new(@client, JSON.parse(results)) end
multiget(*jids)
click to toggle source
# File lib/qless.rb, line 98 def multiget(*jids) results = JSON.parse(@client.call('multiget', *jids)) results.map do |data| Job.new(@client, data) end end
tagged(tag, offset = 0, count = 25)
click to toggle source
# File lib/qless.rb, line 67 def tagged(tag, offset = 0, count = 25) results = JSON.parse(@client.call('tag', 'get', tag, offset, count)) # Should be an empty array instead of an empty hash results['jobs'] = [] if results['jobs'] == {} results end
tracked()
click to toggle source
# File lib/qless.rb, line 61 def tracked results = JSON.parse(@client.call('track')) results['jobs'] = results['jobs'].map { |j| Job.new(@client, j) } results end