Class: Codec::Binary
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#add_sub_codec, #decode, #decode_with_length, #encode_with_length, #eval_length, #get_length, #get_sub_codecs, #initialize
Constructor Details
This class inherits a constructor from Codec::Base
Instance Method Details
#build_field(buf, length) ⇒ Object
74 75 76 77 78 |
# File 'lib/codec/fix.rb', line 74 def build_field(buf,length) f = Field.new(@id) f.set_value(buf[0,length].unpack("H*").first.upcase) return f end |
#encode(f) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/codec/fix.rb', line 80 def encode(f) out = [f.get_value].pack("H*") if @length > 0 raise TooLongDataException if out.length > @length out = out.ljust(@length,0.chr) end return out end |