Class: OrganizzeImporter::Importer

Inherits:
Object
  • Object
show all
Defined in:
lib/organizze_importer/importer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_or_path) ⇒ Importer

Returns a new instance of Importer.



9
10
11
12
# File 'lib/organizze_importer/importer.rb', line 9

def initialize(file_or_path)
  @file = guess_if_is_file_or_path(file_or_path)
  @parser = choose_parsers_based_on_extension
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/organizze_importer/importer.rb', line 24

def method_missing(method, *args)
  if parser.main_fields.include?(method.to_sym)
    parser.send(method, *args)
  else
    super
  end
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



6
7
8
# File 'lib/organizze_importer/importer.rb', line 6

def file
  @file
end

#parserObject (readonly)

Returns the value of attribute parser.



7
8
9
# File 'lib/organizze_importer/importer.rb', line 7

def parser
  @parser
end

Instance Method Details

#ofx?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/organizze_importer/importer.rb', line 20

def ofx?
  file_extension == "ofx"
end

#parse!Object



14
15
16
# File 'lib/organizze_importer/importer.rb', line 14

def parse!
  parser.parse!
end