Class: Mindee::Product::FR::BankStatement::BankStatementV2Transactions

Inherits:
Array
  • Object
show all
Defined in:
lib/mindee/product/fr/bank_statement/bank_statement_v2_transactions.rb

Overview

The list of values that represent the financial transactions recorded in a bank statement.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prediction, page_id) ⇒ BankStatementV2Transactions

Returns a new instance of BankStatementV2Transactions.

Parameters:

  • prediction (Array)
  • page_id (Integer, nil)


17
18
19
20
21
22
# File 'lib/mindee/product/fr/bank_statement/bank_statement_v2_transactions.rb', line 17

def initialize(prediction, page_id)
  entries = prediction.map do |entry|
    BankStatement::BankStatementV2Transaction.new(entry, page_id)
  end
  super(entries)
end

Instance Attribute Details

#entriesArray<BankStatementV2Transaction> (readonly)

Entries.

Returns:



13
14
15
# File 'lib/mindee/product/fr/bank_statement/bank_statement_v2_transactions.rb', line 13

def entries
  @entries
end

Class Method Details

.line_items_separator(char) ⇒ String

Creates a line of rST table-compliant string separators.

Parameters:

  • char (String)

    Character to use as a separator.

Returns:

  • (String)


27
28
29
30
31
32
33
# File 'lib/mindee/product/fr/bank_statement/bank_statement_v2_transactions.rb', line 27

def self.line_items_separator(char)
  out_str = String.new
  out_str << "+#{char * 12}"
  out_str << "+#{char * 12}"
  out_str << "+#{char * 38}"
  out_str
end

Instance Method Details

#to_sString

Returns:

  • (String)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/mindee/product/fr/bank_statement/bank_statement_v2_transactions.rb', line 36

def to_s
  return '' if empty?

  lines = map do |entry|
    "\n  #{entry.to_table_line}\n#{self.class.line_items_separator('-')}"
  end.join
  out_str = String.new
  out_str << ("\n#{self.class.line_items_separator('-')}\n ")
  out_str << ' | Amount    '
  out_str << ' | Date      '
  out_str << ' | Description                         '
  out_str << (" |\n#{self.class.line_items_separator('=')}")
  out_str + lines
end