Class: Processors::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/ynab_convert/processors/processor.rb

Overview

A processor instantiates the Documents and Transformers required to turn a Statement into a YNAB4File

Direct Known Subclasses

Example, N26, UBSChequing, UBSCredit, Wise

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Processor

Returns a new instance of Processor.

Parameters:

  • statement (Documents::Statement)

    The CSV statement to process

  • ynab4_file (Documents::YNAB4Files::YNAB4File)

    An instance of YNAB4File

  • converters (Hash<Symbol, Proc>)

    A hash of converters to process each Statement row. The key is the name of the custom converter. The Proc receives the cell’s content as a string and returns the converted value. See CSV::Converters.

  • transformers (Array<Transformers::Transformer>)

    The Transformers to run in sequense



21
22
23
24
25
26
27
28
# File 'lib/ynab_convert/processors/processor.rb', line 21

def initialize(options = {})
  @statement = options[:statement]
  @transformers = options[:transformers]
  @validators = [::Validators::YNAB4Row]
  @uid = rand(36**8).to_s(36)
  @ynab4_file = options[:ynab4_file]
  register_converters(options[:converters] || {})
end

Instance Method Details

#to_ynab!Object



30
31
32
33
# File 'lib/ynab_convert/processors/processor.rb', line 30

def to_ynab!
  convert
  rename_temp_file
end