Class: YnabConvert::File

Inherits:
Object
  • Object
show all
Includes:
YnabLogger
Defined in:
lib/ynab_convert.rb

Overview

Operations on the CSV file to convert

Instance Method Summary collapse

Methods included from YnabLogger

#logger

Constructor Details

#initialize(opts) ⇒ File

CSV file

Parameters:

  • opts (Hash)

    a customizable set of options

Options Hash (opts):

  • :file (String)

    The filename or path to the file

  • :processor (Processor)

    The class to use for converting the



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ynab_convert.rb', line 33

def initialize(opts)
  logger.debug opts.to_h
  @file = opts[:file]

  begin
    @processor = opts[:processor].new(
      filepath: @file
    )
  rescue Errno::ENOENT
    handle_file_not_found
  end
end

Instance Method Details

#to_ynab!String

Converts @file to YNAB4 format and writes it to disk

Returns:

  • (String)

    The path to the YNAB4 formatted CSV file created



48
49
50
51
# File 'lib/ynab_convert.rb', line 48

def to_ynab!
  logger.debug "Processing `#{@file}' through `#{@processor.class.name}'"
  @processor.to_ynab!
end