class CSVDecision::Table
Decision
table that accepts an input hash and outputs a decision (hash).
Attributes
@return [CSVDecision::Columns] Dictionary
of all input and output columns.
@return [File, Pathname, nil] File path name if decision table was loaded from a CSV file.
@return [Array<CSVDecision::ScanRow>] Used to implement filtering of final results. @api private
@return [CSVDecision::Index] The index built on one or more input columns.
@return [Hash] All options, explicitly set or defaulted, used to parse the table.
Set if the table row has any output functions (planned feature) @api private
@return [Array<CSVDecision::ScanRow>] Used to implement outputting of final results. @api private
@return [CSVDecision::Path] The array of paths built on one or more input columns.
@return [Array<Array>] Data
rows after parsing. @api private
@return [Array<CSVDecision::ScanRow>] Scanning objects used to implement input
matching logic.
@api private
Public Class Methods
@api private
# File lib/csv_decision/table.rb, line 83 def initialize @paths = [] @outs_rows = [] @if_rows = [] @rows = [] @scan_rows = [] end
Public Instance Methods
Unsafe version of decide - may mutate the input hash and assumes the input hash is symbolized.
@param input (see decide
) @note Input
hash must have its keys symbolized.
Input hash will be mutated by any functions that have side effects.
@return (see decide
)
# File lib/csv_decision/table.rb, line 26 def decide!(input) decision( input: input, symbolize_keys: false) end
Iterate through all data rows of the decision table, with an optional first and last row index given.
@param first [Integer] Start row. @param last [Integer, nil] Last row. @api private
# File lib/csv_decision/table.rb, line 73 def each(first = 0, last = @rows.count - 1) index = first while index <= last yield(@rows[index], index) index += 1 end end
Private Instance Methods
# File lib/csv_decision/table.rb, line 93 def decision(input:, symbolize_keys:) if columns.paths.empty? Decision.make(table: self, input: input, symbolize_keys: symbolize_keys) else Scan.table(table: self, input: input, symbolize_keys: symbolize_keys) end end