Class: Eye::Client
Instance Attribute Summary collapse
-
#socket_path ⇒ Object
readonly
Returns the value of attribute socket_path.
Instance Method Summary collapse
- #attempt_command(pack) ⇒ Object
- #command(cmd, *args) ⇒ Object
-
#initialize(socket_path) ⇒ Client
constructor
A new instance of Client.
- #send_request(pack) ⇒ Object
Constructor Details
#initialize(socket_path) ⇒ Client
Returns a new instance of Client.
7 8 9 |
# File 'lib/eye/client.rb', line 7 def initialize(socket_path) @socket_path = socket_path end |
Instance Attribute Details
#socket_path ⇒ Object (readonly)
Returns the value of attribute socket_path.
5 6 7 |
# File 'lib/eye/client.rb', line 5 def socket_path @socket_path end |
Instance Method Details
#attempt_command(pack) ⇒ Object
15 16 17 18 19 |
# File 'lib/eye/client.rb', line 15 def attempt_command(pack) Timeout.timeout(Eye::Local.client_timeout) { send_request(pack) } rescue Timeout::Error, EOFError :timeouted end |
#command(cmd, *args) ⇒ Object
11 12 13 |
# File 'lib/eye/client.rb', line 11 def command(cmd, *args) attempt_command(Marshal.dump([cmd, *args])) end |
#send_request(pack) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/eye/client.rb', line 21 def send_request(pack) UNIXSocket.open(@socket_path) do |socket| socket.write(pack) data = socket.read Marshal.load(data) rescue :corrupted_data end end |