Class: Backburner::Client

Inherits:
BackburnerObject show all
Defined in:
lib/backburner/client.rb

Instance Attribute Summary collapse

Attributes inherited from BackburnerObject

#handler

Instance Method Summary collapse

Methods inherited from BackburnerObject

#method_missing, #reload

Constructor Details

#initialize(host, port = 3234) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
13
# File 'lib/backburner/client.rb', line 7

def initialize host, port=3234
  @host = host
  @port = port
  @connection = Connection.new @host, @port
  send_client_info
  self
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Backburner::BackburnerObject

Instance Attribute Details

#raw_dataObject (readonly)

Returns the value of attribute raw_data.



5
6
7
# File 'lib/backburner/client.rb', line 5

def raw_data
  @raw_data
end

Instance Method Details

#connectObject



15
16
17
# File 'lib/backburner/client.rb', line 15

def connect
  @connection = Connection.new @host, @port
end

#disconnectObject



19
20
21
# File 'lib/backburner/client.rb', line 19

def disconnect
  @connection.close
end

#jobsObject



23
24
25
26
27
28
29
30
31
# File 'lib/backburner/client.rb', line 23

def jobs
  response = @connection.jobhlist.get
  return [] if @connection.empty?
  job_handlers = response.jobh_list.job
  job_handlers = [job_handlers] unless job_handlers.kind_of?(Array)
  job_handlers.map do |job_data|
    Job.new job_data.handle, @connection
  end
end