Class: ISO8583::BCDField

Inherits:
Field
  • Object
show all
Defined in:
lib/iso8583/field.rb

Instance Attribute Summary

Attributes inherited from Field

#bmp, #codec, #max, #name, #padding

Instance Method Summary collapse

Methods inherited from Field

#encode, #parse

Instance Method Details

#lengthObject

This corrects the length for BCD fields, as their encoded length is half (+ parity) of the content length. E.g. 123 (length = 3) encodes to “x01x23” (length 2)



84
85
86
87
# File 'lib/iso8583/field.rb', line 84

def length
  _length = super
  (_length % 2) != 0 ? (_length / 2) + 1 : _length / 2
end