Class: Codec::Numace

Inherits:
Numstr show all
Defined in:
lib/codec/fix.rb

Instance Attribute Summary

Attributes inherited from Base

#id

Instance Method Summary collapse

Methods inherited from Numstr

#encode

Methods inherited from Base

#add_sub_codec, #decode, #decode_with_length, #encode, #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



160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/codec/fix.rb', line 160

def build_field(buf,length)
  f = Field.new(@id)
  
  data = ""
  # if buf to decode is in EBCDIC then convert buf in ASCII
  if ( buf[0,length].unpack("C*").select{|c| c >= 128}.size > 0)
    buf[0,length].unpack("C*").each { |c| data += EBCDIC_2_ASCII[c] }
  else
    data = buf[0,length]
  end
  f.set_value(data.to_i)
  return f
end