Class: Guevara::FileHeader

Inherits:
Row
  • Object
show all
Defined in:
lib/guevara/file_header.rb

Instance Attribute Summary

Attributes inherited from Row

#attributes

Instance Method Summary collapse

Methods inherited from Row

#initialize, #to_s

Constructor Details

This class inherits a constructor from Guevara::Row

Instance Method Details

#default_attributesObject



7
8
9
# File 'lib/guevara/file_header.rb', line 7

def default_attributes
  { reference: 0 }
end

#fieldsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/guevara/file_header.rb', line 16

def fields
  ["1",
   "%<priority_code>02d",
   " %<destination_id>09d",
   " %<origin_id>09d",
   "%<created_at>10.10s",
   "%<id>1.1s",
   "094", # record size is fixed
   "10",  # blocking factor
   "1",   # format code
   "%<destination_name>23.23s",
   "%<origin_name>23.23s",
   "%<reference>8d"]
end

#format_attributesObject



11
12
13
14
# File 'lib/guevara/file_header.rb', line 11

def format_attributes
  attributes[:created_at] = DateTime.parse(attributes[:created_at]).
    strftime('%y%m%d%H%M')
end