Class: Cql::Protocol::FrameDecoder
- Inherits:
-
Object
- Object
- Cql::Protocol::FrameDecoder
- Defined in:
- lib/cql/protocol/frame_decoder.rb
Defined Under Namespace
Classes: CompleteFrame, NullFrame, PartialFrame
Instance Method Summary collapse
- #decode_frame(buffer, partial_frame = nil) ⇒ Object
-
#initialize(compressor = nil) ⇒ FrameDecoder
constructor
A new instance of FrameDecoder.
Constructor Details
#initialize(compressor = nil) ⇒ FrameDecoder
Returns a new instance of FrameDecoder.
6 7 8 |
# File 'lib/cql/protocol/frame_decoder.rb', line 6 def initialize(compressor=nil) @compressor = compressor end |
Instance Method Details
#decode_frame(buffer, partial_frame = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cql/protocol/frame_decoder.rb', line 10 def decode_frame(buffer, partial_frame=nil) partial_frame ||= NULL_FRAME if partial_frame == NULL_FRAME buffer_length = buffer.length return NULL_FRAME if buffer_length < 8 fields = buffer.read_int size = buffer.read_int if buffer_length - 8 >= size actual_decode(buffer, fields, size) else PartialFrame.new(fields, size) end elsif buffer.length >= partial_frame.size actual_decode(buffer, partial_frame.fields, partial_frame.size) else partial_frame end end |