Class: Specwrk::IPC

Inherits:
Object
  • Object
show all
Defined in:
lib/specwrk/ipc.rb

Instance Method Summary collapse

Constructor Details

#initializeIPC

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

#readObject



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