Class: Codec::Strace

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

Instance Attribute Summary

Attributes inherited from Base

#id

Instance Method Summary collapse

Methods inherited from String

#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



176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/codec/fix.rb', line 176

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)
  return f
end