Class: Codec::String

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



57
58
59
60
61
# File 'lib/codec/fix.rb', line 57

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

#encode(f) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/codec/fix.rb', line 63

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