Class: CSVDecision::Index Private
- Inherits:
-
Object
- Object
- CSVDecision::Index
- Defined in:
- lib/csv_decision/index.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Build an index for a decision table with one or more input columns designated as keys
Instance Attribute Summary collapse
-
#columns ⇒ Array<Integer>
readonly
private
Array of column indices.
-
#hash ⇒ Hash
readonly
private
The index hash mapping in input values to one or more data array row indexes.
Class Method Summary collapse
-
.build(table:) ⇒ CSVDecision::Index
private
Build the index on the designated number of input columns.
-
.value(current_value, index) ⇒ Integer, Array
private
New index key value.
Instance Method Summary collapse
-
#initialize(table:, columns:) ⇒ Index
constructor
private
A new instance of Index.
Constructor Details
#initialize(table:, columns:) ⇒ Index
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.
Returns a new instance of Index.
79 80 81 82 83 84 85 86 |
# File 'lib/csv_decision/index.rb', line 79 def initialize(table:, columns:) @columns = columns @hash = {} build(table) freeze end |
Instance Attribute Details
#columns ⇒ Array<Integer> (readonly)
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.
Returns Array of column indices.
75 76 77 |
# File 'lib/csv_decision/index.rb', line 75 def columns @columns end |
#hash ⇒ Hash (readonly)
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.
Returns The index hash mapping in input values to one or more data array row indexes.
72 73 74 |
# File 'lib/csv_decision/index.rb', line 72 def hash @hash end |
Class Method Details
.build(table:) ⇒ CSVDecision::Index
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.
Build the index on the designated number of input columns.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/csv_decision/index.rb', line 16 def self.build(table:) # Do we even have an index? key_cols = index_columns(columns: table.columns.ins) return if key_cols.empty? table.index = Index.new(table: table, columns: key_cols) # Indexed columns do not need to be scanned trim_scan_rows(scan_rows: table.scan_rows, index_columns: table.index.columns) table end |
.value(current_value, index) ⇒ Integer, Array
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.
Returns New index key value.
32 33 34 35 36 37 38 |
# File 'lib/csv_decision/index.rb', line 32 def self.value(current_value, index) return integer_value(current_value, index) if current_value.is_a?(Integer) array_value(current_value, index) current_value end |