module CSVDecision::Load

Load all CSV files located in the specified folder. @api private

Public Class Methods

path(path:, options:) click to toggle source

(see CSVDecision.load)

# File lib/csv_decision/load.rb, line 23
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