class Del::SocketMessage
Public Class Methods
new(shell, socket_file:)
click to toggle source
# File lib/del/socket_message.rb, line 5 def initialize(shell, socket_file:) @shell = shell @socket_file = socket_file end
Public Instance Methods
close()
click to toggle source
# File lib/del/socket_message.rb, line 23 def close socket&.close end
deliver(payload)
click to toggle source
# File lib/del/socket_message.rb, line 10 def deliver(payload) socket.puts(message_for(payload)) rescue EOFError => error @shell.say error.message, :red rescue Errno::ECONNREFUSED => error @shell.say error.message, :red @shell.say 'You must start the del server first.', :yellow end
listen()
click to toggle source
# File lib/del/socket_message.rb, line 19 def listen socket.readline end
Private Instance Methods
message_for(payload)
click to toggle source
# File lib/del/socket_message.rb, line 29 def message_for(payload) JSON.generate(payload) end
socket()
click to toggle source
# File lib/del/socket_message.rb, line 33 def socket @socket ||= UNIXSocket.new(@socket_file) end