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

Instance Method Details

#contentString

Returns:

  • (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_linesObject

Raises:

  • (NotImplementedError)


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_lineUnionBank::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

Parameters:

  • org_short_code (String)
  • date (Date)
  • total_no_of_refs (Integer) (defaults to: 0)
  • details (Array) (defaults to: [])


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