Class: Net::InternetMessageIO
- Inherits:
-
BufferedIO
- Object
- BufferedIO
- Net::InternetMessageIO
- Defined in:
- lib/net/protocol.rb
Overview
:nodoc: internal use only
Instance Attribute Summary
Attributes inherited from BufferedIO
#continue_timeout, #debug_output, #io, #read_timeout, #write_timeout
Instance Method Summary collapse
-
#each_list_item ⇒ Object
*library private* (cannot handle ‘break’).
-
#each_message_chunk ⇒ Object
Read.
-
#initialize ⇒ InternetMessageIO
constructor
A new instance of InternetMessageIO.
-
#write_message(src) ⇒ Object
Write.
- #write_message_0(src) ⇒ Object
- #write_message_by_block(&block) ⇒ Object
Methods inherited from BufferedIO
#close, #closed?, #eof?, #inspect, #read, #read_all, #readline, #readuntil, #write, #writeline
Constructor Details
#initialize ⇒ InternetMessageIO
Returns a new instance of InternetMessageIO.
327 328 329 330 |
# File 'lib/net/protocol.rb', line 327 def initialize(*, **) super @wbuf = nil end |
Instance Method Details
#each_list_item ⇒ Object
*library private* (cannot handle ‘break’)
349 350 351 352 353 |
# File 'lib/net/protocol.rb', line 349 def each_list_item while (str = readuntil("\r\n")) != ".\r\n" yield str.chop end end |
#each_message_chunk ⇒ Object
Read
336 337 338 339 340 341 342 343 344 345 346 |
# File 'lib/net/protocol.rb', line 336 def LOG 'reading message...' LOG_off() read_bytes = 0 while (line = readuntil("\r\n")) != ".\r\n" read_bytes += line.size yield line.delete_prefix('.') end LOG_on() LOG "read message (#{read_bytes} bytes)" end |
#write_message(src) ⇒ Object
Write
367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/net/protocol.rb', line 367 def (src) LOG "writing message from #{src.class}" LOG_off() len = writing { using_each_crlf_line { src } } LOG_on() LOG "wrote #{len} bytes" len end |
#write_message_0(src) ⇒ Object
355 356 357 358 359 360 361 |
# File 'lib/net/protocol.rb', line 355 def (src) prev = @written_bytes each_crlf_line(src) do |line| write0 dot_stuff(line) end @written_bytes - prev end |
#write_message_by_block(&block) ⇒ Object
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
# File 'lib/net/protocol.rb', line 380 def (&block) LOG 'writing message from block' LOG_off() len = writing { using_each_crlf_line { begin block.call(WriteAdapter.new(self, :write_message_0)) rescue LocalJumpError # allow `break' from writer block end } } LOG_on() LOG "wrote #{len} bytes" len end |