Module: CSVDecision::Parse Private
- Defined in:
- lib/csv_decision/parse.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Methods to parse the decision table and return CSVDecision::Table object.
Class Method Summary collapse
- .ins_cell_dictionary(columns:, cell:) ⇒ Object private
- .invalid_out_ref?(columns, index, in_out) ⇒ Boolean private
-
.table(data:, options:) ⇒ CSVDecision::Table
private
Parse the CSV file or input data and create a new decision table object.
Class Method Details
.ins_cell_dictionary(columns:, cell:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
219 220 221 222 223 224 |
# File 'lib/csv_decision/parse.rb', line 219 def self.ins_cell_dictionary(columns:, cell:) return unless cell.is_a?(Matchers::Proc) return if cell.symbols.nil? add_ins_symbols(columns: columns, cell: cell) end |
.invalid_out_ref?(columns, index, in_out) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/csv_decision/parse.rb', line 202 def self.invalid_out_ref?(columns, index, in_out) return false if in_out < index that_column = if in_out == index 'reference to itself' else "an out of order reference to output column '#{columns.outs[in_out].name}'" end raise CellValidationError, "output column '#{columns.outs[index].name}' makes #{that_column}" end |
.table(data:, options:) ⇒ CSVDecision::Table
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parse the CSV file or input data and create a new decision table object.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/csv_decision/parse.rb', line 57 def self.table(data:, options:) table = CSVDecision::Table.new # In most cases the decision table will be loaded from a CSV file. table.file = data if Data.input_file?(data) parse_table(table: table, input: data, options: ) # The table object is now immutable. table.columns.freeze table.freeze rescue CSVDecision::Error => exp raise_error(file: table.file, exception: exp) end |