Class: ZMQMachine::LogServer
- Inherits:
-
Object
- Object
- ZMQMachine::LogServer
- Includes:
- Server::SUB
- Defined in:
- lib/zm/log_server.rb
Instance Method Summary collapse
-
#initialize(configuration) ⇒ LogServer
constructor
A new instance of LogServer.
-
#on_read(socket, messages) ⇒ Object
Writes all messages to the file.
- #write(messages) ⇒ Object
Methods included from Server::Base
#on_attach, #on_readable, #on_readable_error, #on_writable, #on_writable_error, #shutdown
Constructor Details
#initialize(configuration) ⇒ LogServer
Returns a new instance of LogServer.
42 43 44 45 46 47 |
# File 'lib/zm/log_server.rb', line 42 def initialize(configuration) configuration.on_read = method(:on_read) super @file = configuration.extra[:file] || STDOUT end |
Instance Method Details
#on_read(socket, messages) ⇒ Object
Writes all messages to the file.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/zm/log_server.rb', line 51 def on_read socket, string = '' .each_with_index do |, index| string << '|' if index > 0 string << "#{.copy_out_string}" end @file.print "#{string}\n" @file.flush end |
#write(messages) ⇒ Object
62 63 64 |
# File 'lib/zm/log_server.rb', line 62 def write # no op end |