Class: Documents::Statements::Statement

Inherits:
Object
  • Object
show all
Defined in:
lib/ynab_convert/documents/statements/statement.rb

Overview

The base Statement class from which other Statements inherit. Represents a CSV statement from a financial institution, typically from its online banking portal.

Direct Known Subclasses

Example, N26, UBSChequing, UBSCredit, Wise

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filepath:, csv_import_options: CSV::DEFAULT_OPTIONS) ⇒ Statement

Returns a new instance of Statement.

Parameters:

  • filepath (String)

    path to the CSV file

  • csv_import_options (CSV::DEFAULT_OPTIONS) (defaults to: CSV::DEFAULT_OPTIONS)

    options describing the particular CSV flavour (column separator, etc). Any CSV::DEFAULT_OPTIONS is valid.



15
16
17
18
19
20
21
22
# File 'lib/ynab_convert/documents/statements/statement.rb', line 15

def initialize(filepath:, csv_import_options: CSV::DEFAULT_OPTIONS)
  validate(filepath)

  default_options = CSV::DEFAULT_OPTIONS.merge(converters: %i[numeric
                                                              date])
  @filepath = filepath
  @csv_import_options = default_options.merge(csv_import_options)
end

Instance Attribute Details

#csv_import_optionsObject (readonly)

Returns the value of attribute csv_import_options.



9
10
11
# File 'lib/ynab_convert/documents/statements/statement.rb', line 9

def csv_import_options
  @csv_import_options
end

#filepathObject (readonly)

Returns the value of attribute filepath.



9
10
11
# File 'lib/ynab_convert/documents/statements/statement.rb', line 9

def filepath
  @filepath
end

Instance Method Details

#institution_nameObject



24
25
26
# File 'lib/ynab_convert/documents/statements/statement.rb', line 24

def institution_name
  self.class.name.split('::').last
end