Class: Xdt::Field

Inherits:
Object
  • Object
show all
Extended by:
FieldHandling
Includes:
Fields
Defined in:
lib/xdt/xdt_fields.rb

Instance Method Summary collapse

Methods included from FieldHandling

define_field

Methods included from Fields

#included

Constructor Details

#initialize(type, data) ⇒ Field

Returns a new instance of Field.



62
63
64
65
# File 'lib/xdt/xdt_fields.rb', line 62

def initialize(type, data)
  @id = type
  @data = data.to_s
end

Instance Method Details

#lengthObject



67
68
69
# File 'lib/xdt/xdt_fields.rb', line 67

def length
  @data.length + 9
end

#to_sObject



71
72
73
# File 'lib/xdt/xdt_fields.rb', line 71

def to_s
  "#{ '%03d'  % self.length }#{ '%04d' % @id.to_i }#{@data}\x0D\x0A"
end