Class: Del::SocketMessage
- Inherits:
-
Object
- Object
- Del::SocketMessage
- Defined in:
- lib/del/socket_message.rb
Instance Method Summary collapse
- #close ⇒ Object
- #deliver(payload) ⇒ Object
-
#initialize(shell, socket_file:) ⇒ SocketMessage
constructor
A new instance of SocketMessage.
- #listen ⇒ Object
Constructor Details
#initialize(shell, socket_file:) ⇒ SocketMessage
Returns a new instance of SocketMessage.
5 6 7 8 |
# File 'lib/del/socket_message.rb', line 5 def initialize(shell, socket_file:) @shell = shell @socket_file = socket_file end |
Instance Method Details
#close ⇒ Object
23 24 25 |
# File 'lib/del/socket_message.rb', line 23 def close socket&.close end |
#deliver(payload) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/del/socket_message.rb', line 10 def deliver(payload) socket.puts((payload)) rescue EOFError => error @shell.say error., :red rescue Errno::ECONNREFUSED => error @shell.say error., :red @shell.say 'You must start the del server first.', :yellow end |
#listen ⇒ Object
19 20 21 |
# File 'lib/del/socket_message.rb', line 19 def listen socket.readline end |