Module: EventMachine::IMAP::CommandSender::LineBuffer

Included in:
EventMachine::IMAP::CommandSender
Defined in:
lib/em-imap/command_sender.rb

Overview

Buffers out-going string sending by-line.

This is safe to do for IMAP because the client always ends transmission on a CRLF (for awaiting continuation requests, and for ending commands)

Instance Method Summary collapse

Instance Method Details

#post_initObject



138
139
140
141
# File 'lib/em-imap/command_sender.rb', line 138

def post_init
  super
  @line_buffer = ""
end

#send_line_buffered(str) ⇒ Object



143
144
145
146
147
148
149
# File 'lib/em-imap/command_sender.rb', line 143

def send_line_buffered(str)
  @line_buffer += str
  while eol = @line_buffer.index(CRLF)
    to_send = @line_buffer.slice! 0, eol + CRLF.size
    send_data to_send
  end
end