Class: Codec::Ebcdic

Inherits:
Base
  • Object
show all
Defined in:
lib/codec/fix.rb

Instance Attribute Summary

Attributes inherited from Base

#id

Instance Method Summary collapse

Methods inherited from Base

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



81
82
83
84
85
# File 'lib/codec/fix.rb', line 81

def build_field(buf,length)
  f = Field.new(@id)
  f.set_value(EightBitsEncoding::EBCDIC_2_UTF8(buf[0,length]))
  return f
end

#encode(f) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/codec/fix.rb', line 87

def encode(f)
  out = f.get_value
  if @length >  0
    raise TooLongDataException if out.length > @length
    out = out.ljust(@length," ")
  end
  return EightBitsEncoding::UTF8_2_EBCDIC(out)
end