Class: Ethmo::IPCSocket
- Inherits:
-
UNIXSocket
- Object
- UNIXSocket
- Ethmo::IPCSocket
- Defined in:
- lib/ethmo/ipc_socket.rb
Overview
:nodoc;
Constant Summary collapse
- VERSION =
'2.0'
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #exec(method, *params) ⇒ Object
-
#initialize(path) ⇒ IPCSocket
constructor
A new instance of IPCSocket.
- #read ⇒ Object
Constructor Details
#initialize(path) ⇒ IPCSocket
Returns a new instance of IPCSocket.
17 18 19 20 21 |
# File 'lib/ethmo/ipc_socket.rb', line 17 def initialize(path) @buffer = '' @id = self.class.next_id super end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
15 16 17 |
# File 'lib/ethmo/ipc_socket.rb', line 15 def id @id end |
Class Method Details
.next_id ⇒ Object
7 8 9 10 |
# File 'lib/ethmo/ipc_socket.rb', line 7 def next_id @id ||= 1 @id += 1 end |
Instance Method Details
#exec(method, *params) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/ethmo/ipc_socket.rb', line 23 def exec(method, *params) send({ id: id, jsonrpc: VERSION, method: method, params: params }.to_json, 0) end |
#read ⇒ Object
32 33 34 35 |
# File 'lib/ethmo/ipc_socket.rb', line 32 def read @buffer = @buffer.to_s + recv(1024) until @buffer.to_s.include?("\n") (_, @buffer = @buffer.to_s.split("\n", 2)).first end |