Class: Xdt::Field
- Inherits:
-
Object
- Object
- Xdt::Field
- Extended by:
- FieldHandling
- Includes:
- Fields
- Defined in:
- lib/xdt/xdt_fields.rb
Instance Method Summary collapse
-
#initialize(type, data) ⇒ Field
constructor
A new instance of Field.
- #length ⇒ Object
- #to_s ⇒ Object
Methods included from FieldHandling
Methods included from Fields
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
#length ⇒ Object
67 68 69 |
# File 'lib/xdt/xdt_fields.rb', line 67 def length @data.length + 9 end |
#to_s ⇒ Object
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 |