Module: UnionBank::ECrediting::PipeDelimitedFile
- Extended by:
- ActiveSupport::Concern
- Included in:
- EnrollmentFile, TransactionFile
- Defined in:
- lib/union_bank/e_crediting/pipe_delimited_file.rb
Overview
Defines common methods of a pipe delimited file (CSV file with “|” as the column separator).
Instance Method Summary collapse
- #content ⇒ String
- #detail_lines ⇒ Object
- #header_line ⇒ UnionBank::ECrediting::Common::HeaderLine
- #initialize(org_short_code:, date:, total_no_of_refs: 0, details: []) ⇒ Object
Instance Method Details
#content ⇒ String
26 27 28 29 30 31 32 33 34 |
# File 'lib/union_bank/e_crediting/pipe_delimited_file.rb', line 26 def content CSV.generate(col_sep: "|", row_sep: "\r\n") do |csv| csv << header_line.ordered_field_values detail_lines.each do |line| csv << line.ordered_field_values end end end |
#detail_lines ⇒ Object
43 44 45 |
# File 'lib/union_bank/e_crediting/pipe_delimited_file.rb', line 43 def detail_lines raise NotImplementedError, "#{self.class} must implement #detail_lines" end |
#header_line ⇒ UnionBank::ECrediting::Common::HeaderLine
37 38 39 40 41 |
# File 'lib/union_bank/e_crediting/pipe_delimited_file.rb', line 37 def header_line @header_line ||= Common::HeaderLine.new org_short_code: org_short_code, date: date, total_no_of_refs: total_no_of_refs end |
#initialize(org_short_code:, date:, total_no_of_refs: 0, details: []) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/union_bank/e_crediting/pipe_delimited_file.rb', line 18 def initialize(org_short_code:, date:, total_no_of_refs: 0, details: []) @org_short_code = org_short_code @date = date @total_no_of_refs = total_no_of_refs @details = details end |