Module: CSVDecision::Load

Defined in:
lib/csv_decision/load.rb

Overview

Load all CSV files located in the specified folder.

Class Method Summary collapse

Class Method Details

.path(path:, options:) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/csv_decision/load.rb', line 18

def self.path(path:, options:)
  raise ArgumentError, 'path argument must be a Pathname' unless path.is_a?(Pathname)
  raise ArgumentError, 'path argument not a valid folder' unless path.directory?

  tables = {}
  Dir[path.join('*.csv')].each do |file_name|
    table_name = File.basename(file_name, '.csv').to_sym
    tables[table_name] = CSVDecision.parse(Pathname(file_name), options)
  end

  tables.freeze
end