Module: CSVDecision::Options
- Defined in:
- lib/csv_decision/options.rb
Overview
Validate and normalize the options values supplied.
Constant Summary collapse
- VALID =
All valid CSVDecision::parse options with their default values.
{ first_match: true, regexp_implicit: false, text_only: false, matchers: DEFAULT_MATCHERS }.freeze
- CSV_NAMES =
These options may appear in the CSV file before the header row. They get converted to a normalized option key value pair.
{ first_match: [:first_match, true], accumulate: [:first_match, false], regexp_implicit: [:regexp_implicit, true], text_only: [:text_only, true] }.freeze
Class Method Summary collapse
-
.from_csv(rows:, options:) ⇒ Hash
Read any options supplied in the CSV file placed before the header row.
-
.normalize(options) ⇒ Hash
Validate options and supply default values for any options not explicitly set.
Class Method Details
.from_csv(rows:, options:) ⇒ Hash
Read any options supplied in the CSV file placed before the header row.
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/csv_decision/options.rb', line 58 def self.from_csv(rows:, options:) row = rows.first return if row.nil? # Have we hit the header row? return if Header.row?(row) # Scan each cell looking for valid option values = scan_cells(row: row, options: ) rows.shift from_csv(rows: rows, options: ) end |
.normalize(options) ⇒ Hash
Validate options and supply default values for any options not explicitly set.
48 49 50 51 |
# File 'lib/csv_decision/options.rb', line 48 def self.normalize() validate() default() end |