Method: Codec::Packed#check_length
- Defined in:
- lib/codec/packed.rb
#check_length(buf, length) ⇒ Object
No more required encode return the field length for upper codec layer def get_length(field)
if @length > 0
return @length
else
return field.get_value.to_s.length
end
end
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/codec/packed.rb', line 19 def check_length(buf,length) raise "Length is nil" if length.nil? if(length != 0) if buf.length < length raise BufferUnderflow, "Not enough data for decoding (#{length}/#{buf.length})" end return length else return buf.length end end |