Class: TestLineText2::ThrowBack

Inherits:
Object
  • Object
show all
Includes:
EM::Protocols::LineText2
Defined in:
lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb

Overview

Test binary data with a “throw back” into line-mode.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ThrowBack

Returns a new instance of ThrowBack.



164
165
166
167
168
169
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb', line 164

def initialize *args
  super
  @headers = []
  @n_bytes = 0
  set_text_mode
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



163
164
165
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb', line 163

def headers
  @headers
end

Instance Method Details

#receive_binary_data(data) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb', line 170

def receive_binary_data data
  wanted = 25 - @n_bytes
  will_take = if data.length > wanted
                data.length - wanted
              else
                data.length
              end
  @n_bytes += will_take

  if @n_bytes == 25
    set_line_mode( data[will_take..-1] )
  end
end

#receive_line(ln) ⇒ Object



183
184
185
# File 'lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb', line 183

def receive_line ln
  @headers << ln
end