Sha256: f8ce4979f07dd14052be0efd4c92479ec52644598640a63e6b5be03e73189e3f
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true # CSV Decision: CSV based Ruby decision tables. # Created December 2017. # @author Brett Vickers <brett@phillips-vickers.com> # See LICENSE and README.md for details. module CSVDecision2 # Load all the CSV files located in the designated folder path. # # @param path [Pathname] Directory containing CSV decision table files. # @param options (see CSVDecision2.parse) # @return [Hash{Symbol=><CSVDecision2::Table>}] Hash of decision tables keyed by the CSV # file's symbolized base name. # @raise [ArgumentError] Invalid path name or folder. def self.load(path, options = {}) Load.path(path: path, options: options) end # Load all CSV files located in the specified folder. # @api private module Load # (see CSVDecision2.load) 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] = CSVDecision2.parse(Pathname(file_name), options) end tables.freeze end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csv_decision2-0.5.2 | lib/csv_decision2/load.rb |