Class: Eye::Client

Inherits:
Object show all
Defined in:
lib/eye/client.rb

Constant Summary collapse

SIGN =
123_566_983

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(socket_path, type = :old) ⇒ Client

Returns a new instance of Client.



8
9
10
11
# File 'lib/eye/client.rb', line 8

def initialize(socket_path, type = :old)
  @socket_path = socket_path
  @type = type
end

Instance Attribute Details

#socket_pathObject (readonly)

Returns the value of attribute socket_path.



6
7
8
# File 'lib/eye/client.rb', line 6

def socket_path
  @socket_path
end

Instance Method Details

#execute(h = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/eye/client.rb', line 15

def execute(h = {})
  payload = if @type == :old
    Marshal.dump([h[:command], *h[:args]]) # TODO: remove in 1.0
  else
    payload = Marshal.dump(h)
    [SIGN, payload.length].pack('N*') + payload
  end
  timeout = h[:timeout] || Eye::Local.client_timeout
  attempt_command(payload, timeout)
end