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