lib/iso8583/field.rb
# may either be some other Field in which the length is encoded or a Fixnum for
# fixed length fields. Length should always be the length of the *encoded* value.
# A 6 digit BCD field will require a length 3, as will a 5 digit BCD field.
# The subclass BCDField handles this to keep things consistant.
may either be some other Field in which the length is encoded or a Fixnum for
fixed length fields. Length should always be the length of the *encoded* value.
A 6 digit BCD field will require a length 3, as will a 5 digit BCD field.
The subclass BCDField handles this to keep things consistant.
may either be some other Field in which the length is encoded or a Fixnum for fixed length fields . Length should always be the length of the * encoded * value . A 6 digit BCD field will require a length 3 as will a 5 digit BCD field . The subclass BCDField handles this to keep things consistant .
def parse(raw)
      len, raw = case length
                 when Integer
                   [length, raw]
                 when Field
                   length.parse(raw)
                 else
                   raise ISO8583Exception.new("Cannot determine the length of '#{name}' field")
                 end
      raw_value = raw[0,len]
      if raw_value.length != len
        mes = "Field (#{name}) has incorrect length! field: #{raw_value} len/expected: #{raw_value.length}/#{len}"
        raise ISO8583ParseException.new(mes)
      end
      rest = raw[len, raw.length]
      begin
        real_value = codec.decode(raw_value)
      rescue => e
        ContextLog.exception e, e.backtrace if Object.const_defined?(:ContextLog)
        raise ISO8583ParseException.new(e.message+" (#{name})")
      end
      [ real_value, rest ]
    end
def parse ( raw ) len , raw = case length when Integer [ length , raw ] when Field length . parse ( raw ) else raise ISO8583Exception . new ( "Cannot determine the length of '#{name}' field" ) end raw_value = raw [ 0 , len ] if raw_value . length != len mes = "Field (#{name}) has incorrect length! field: #{raw_value} len/expected: #{raw_value.length}/#{len}" raise ISO8583ParseException . new ( mes ) end rest = raw [ len , raw . length ] begin real_value = codec . decode ( raw_value ) rescue => e ContextLog . exception e , e . backtrace if Object . const_defined? ( :ContextLog ) raise ISO8583ParseException . new ( e . message + " (#{name})" ) end [ real_value , rest ] end
may either be some other Field in which the length is encoded or a Fixnum for
fixed length fields.
may either be some other Field in which the length is encoded or a Fixnum for fixed length fields .
# make sure we have enough data ...
raw
<not_specific>