Class: Rucoa::MessageWriter
- Inherits:
-
Object
- Object
- Rucoa::MessageWriter
- Defined in:
- lib/rucoa/message_writer.rb
Instance Attribute Summary collapse
- #io ⇒ IO readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(io) ⇒ MessageWriter
constructor
A new instance of MessageWriter.
- #write(message) ⇒ void
Constructor Details
#initialize(io) ⇒ MessageWriter
Returns a new instance of MessageWriter.
26 27 28 29 |
# File 'lib/rucoa/message_writer.rb', line 26 def initialize(io) @io = io @io.binmode end |
Instance Attribute Details
#io ⇒ IO (readonly)
23 24 25 |
# File 'lib/rucoa/message_writer.rb', line 23 def io @io end |
Class Method Details
.pack(message) ⇒ String
16 17 18 19 |
# File 'lib/rucoa/message_writer.rb', line 16 def pack() body = DEFAULT_MESSAGE.merge().to_json "Content-Length: #{body.bytesize}\r\n\r\n#{body}" end |
Instance Method Details
#write(message) ⇒ void
This method returns an undefined value.
33 34 35 36 37 38 |
# File 'lib/rucoa/message_writer.rb', line 33 def write() @io.print( self.class.pack() ) @io.flush end |