Class: Cod::LineSerializer
- Inherits:
-
Object
- Object
- Cod::LineSerializer
- Defined in:
- lib/cod/line_serializer.rb
Overview
A serializer that implements a line by line wire protocol. Only strings can be sent. An instance of this class can be used when constructing any channel, turning it into a line oriented channel speaking a clear text protocol.
Instance Method Summary collapse
-
#de(io) ⇒ String
Deserializes a message from the wire.
-
#en(msg) ⇒ String
Turns a message into the wire format.
Instance Method Details
#de(io) ⇒ String
Deserializes a message from the wire.
23 24 25 26 27 |
# File 'lib/cod/line_serializer.rb', line 23 def de(io) msg = io.gets return msg.chomp if msg raise EOFError end |
#en(msg) ⇒ String
Turns a message into the wire format.
14 15 16 |
# File 'lib/cod/line_serializer.rb', line 14 def en(msg) msg.to_s + "\n" end |