Class: Codec::Numstr
Instance Method Summary collapse
Methods inherited from Fix
#check_length, #decode, #initialize
Methods inherited from Base
#add_sub_codec, #decode, #get_sub_codecs
Constructor Details
This class inherits a constructor from Codec::Fix
Instance Method Details
#build_field(buf, f, length) ⇒ Object
68 69 70 |
# File 'lib/codec/fix.rb', line 68 def build_field(buf, f, length) f.set_value(buf.slice!(0...length).to_i) end |
#encode(buf, field) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/codec/fix.rb', line 72 def encode(buf,field) out = field.get_value.to_s if @length > 0 out = out.rjust(@length,"0") raise TooLongDataException if out.length > @length end buf << out return out.length end |