Class: CSVDecision::Paths Private
- Inherits:
-
Object
- Object
- CSVDecision::Paths
- Defined in:
- lib/csv_decision/paths.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
-
#paths ⇒ Hash
readonly
private
The index hash mapping in input values to one or more data array row indexes.
Class Method Summary collapse
-
.scan(table:) ⇒ CSVDecision::Paths
private
Build the index of paths.
-
.symbol(value) ⇒ nil, Symbol
private
Non-empty string converted to a symbol.
-
.value(current_value, index) ⇒ Integer, Array
private
New path key value.
Instance Method Summary collapse
-
#initialize(table:, columns:) ⇒ Paths
constructor
private
A new instance of Paths.
Constructor Details
#initialize(table:, columns:) ⇒ Paths
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 Paths.
45 46 47 48 49 50 51 52 |
# File 'lib/csv_decision/paths.rb', line 45 def initialize(table:, columns:) @paths = [] @columns = columns build(table) freeze end |
Instance Attribute Details
#paths ⇒ 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.
41 42 43 |
# File 'lib/csv_decision/paths.rb', line 41 def paths @paths end |
Class Method Details
.scan(table:) ⇒ CSVDecision::Paths
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 of paths
16 17 18 19 20 21 22 |
# File 'lib/csv_decision/paths.rb', line 16 def self.scan(table:) # Do we even have paths? columns = table.columns.paths.keys return [] if columns.empty? table.paths = Paths.new(table: table, columns: columns).paths end |
.symbol(value) ⇒ nil, Symbol
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 Non-empty string converted to a symbol.
36 37 38 |
# File 'lib/csv_decision/paths.rb', line 36 def self.symbol(value) value.blank? ? nil : value.to_sym 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 path key value.
27 28 29 30 31 32 |
# File 'lib/csv_decision/paths.rb', line 27 def self.value(current_value, index) return [current_value, index] if current_value.is_a?(Integer) current_value[-1] = index current_value end |