Class: Specwrk::IPC
- Inherits:
-
Object
- Object
- Specwrk::IPC
- Defined in:
- lib/specwrk/ipc.rb
Instance Method Summary collapse
-
#initialize ⇒ IPC
constructor
A new instance of IPC.
- #read ⇒ Object
- #write(msg) ⇒ Object
Constructor Details
#initialize ⇒ IPC
Returns a new instance of IPC.
5 6 7 8 9 |
# File 'lib/specwrk/ipc.rb', line 5 def initialize @parent_pid = Process.pid @parent_socket, @child_socket = UNIXSocket.pair end |
Instance Method Details
#read ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/specwrk/ipc.rb', line 15 def read IO.select([socket]) data = socket.gets&.chomp return if data.nil? || data.length.zero? || data == "INT" data end |
#write(msg) ⇒ Object
11 12 13 |
# File 'lib/specwrk/ipc.rb', line 11 def write(msg) socket.puts msg.to_s end |