class Eye::Client
Attributes
socket_path[R]
Public Class Methods
new(socket_path)
click to toggle source
# File lib/eye/client.rb, line 7 def initialize(socket_path) @socket_path = socket_path end
Public Instance Methods
attempt_command(pack)
click to toggle source
# File lib/eye/client.rb, line 15 def attempt_command(pack) Timeout.timeout(Eye::Local.client_timeout) do return send_request(pack) end rescue Timeout::Error, EOFError :timeouted end
command(cmd, *args)
click to toggle source
# File lib/eye/client.rb, line 11 def command(cmd, *args) attempt_command(Marshal.dump([cmd, *args])) end
send_request(pack)
click to toggle source
# File lib/eye/client.rb, line 24 def send_request(pack) UNIXSocket.open(@socket_path) do |socket| socket.write(pack) data = socket.read res = Marshal.load(data) rescue :corrupted_data end end