Module: ExtrasDeCont

Defined in:
lib/extras_de_cont.rb,
lib/extras_de_cont/parser.rb,
lib/extras_de_cont/rules/base.rb,
lib/extras_de_cont/transaction.rb,
lib/extras_de_cont/rules/revolut.rb,
lib/extras_de_cont/rules/unicredit.rb

Overview

The ExtrasDeCont module contains utilities for parsing bank statements.

Defined Under Namespace

Modules: Rules Classes: Parser, Transaction

Constant Summary collapse

BANK_RULES =

Map of supported banks (symbol → rule class)

{
  unicredit: Rules::UniCredit,
  revolut: Rules::Revolut
}.freeze

Class Method Summary collapse

Class Method Details

.parse(file, bank:) ⇒ Array<ExtrasDeCont::Transaction>

Parses a PDF bank statement and returns structured transactions.

Parameters:

  • file (String, Pathname, IO)

    path to the PDF file or an IO-like object

  • bank (Symbol)

    the bank identifier (:unicredit, :revolut, etc.)

Returns:

Raises:

  • (ArgumentError)

    if the bank is not supported



23
24
25
26
27
28
29
# File 'lib/extras_de_cont.rb', line 23

def parse(file, bank:)
  rule_class = BANK_RULES[bank]
  raise ArgumentError, "Unsupported bank: #{bank}. Supported banks: #{BANK_RULES.keys.join(", ")}" unless rule_class

  p = Parser.new(file)
  p.parse_with(rule_class.new)
end