Class: Codec::Numasc
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
40 41 42 43 44 |
# File 'lib/codec/fix.rb', line 40 def build_field(buf,length) f = Field.new(@id) f.set_value(buf[0,length].to_i) return f end |
#encode(field) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/codec/fix.rb', line 46 def encode(field) out = field.get_value.to_s if @length > 0 out = out.rjust(@length,"0") raise TooLongDataException if out.length > @length end return out end |