Class: CSVDecision::Columns Private
- Inherits:
-
Object
- Object
- CSVDecision::Columns
- Defined in:
- lib/csv_decision/columns.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.
Dictionary of all this table’s columns - inputs, outputs etc.
Defined Under Namespace
Classes: Dictionary
Class Method Summary collapse
- .ins_cell_dictionary(columns:, cell:) ⇒ void private
- .ins_dictionary(columns:, row:) ⇒ void private
- .outs_dictionary(columns:, row:) ⇒ void private
Instance Method Summary collapse
-
#defaults ⇒ Object
private
Input columns with defaults specified.
-
#defaults=(value) ⇒ Object
private
Set defaults for columns with defaults specified.
-
#dictionary ⇒ Hash{Symbol=>[false, Integer]}
private
Dictionary of all input and output column names.
-
#ifs ⇒ Hash{Index=>Entry}
private
if: columns hash keyed by column index.
-
#initialize(table) ⇒ Columns
constructor
private
A new instance of Columns.
-
#input_keys ⇒ Array<Symbol>
private
All input column symbols.
-
#ins ⇒ Hash{Index=>Entry}
private
Input columns hash keyed by column index.
-
#outs ⇒ Hash{Index=>Entry}
private
Output columns hash keyed by column index.
-
#paths ⇒ Hash{Index=>Entry}
private
path: columns hash keyed by column index.
Constructor Details
#initialize(table) ⇒ Columns
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 Columns.
178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/csv_decision/columns.rb', line 178 def initialize(table) # If a column does not have a valid header cell, then it's empty of data. # Return the stripped header row, and remove it from the data array. row = Header.strip_empty_columns(rows: table.rows) # No header row found? raise TableValidationError, 'table has no header row' unless row # Build a dictionary of all valid data columns from the header row. @dictionary = CSVDecision::Dictionary.build(header: row, dictionary: Dictionary.new) freeze end |
Class Method Details
.ins_cell_dictionary(columns:, cell:) ⇒ void
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.
This method returns an undefined value.
30 31 32 33 34 35 |
# File 'lib/csv_decision/columns.rb', line 30 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 |
.ins_dictionary(columns:, row:) ⇒ void
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.
This method returns an undefined value.
23 24 25 |
# File 'lib/csv_decision/columns.rb', line 23 def self.ins_dictionary(columns:, row:) row.each { |cell| ins_cell_dictionary(columns: columns, cell: cell) } end |
.outs_dictionary(columns:, row:) ⇒ void
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.
This method returns an undefined value.
14 15 16 17 18 |
# File 'lib/csv_decision/columns.rb', line 14 def self.outs_dictionary(columns:, row:) row.each_with_index do |cell, index| outs_check_cell(columns: columns, cell: cell, index: index) end end |
Instance Method Details
#defaults ⇒ 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.
Input columns with defaults specified
133 134 135 |
# File 'lib/csv_decision/columns.rb', line 133 def defaults @dictionary&.defaults end |
#defaults=(value) ⇒ 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.
Set defaults for columns with defaults specified
138 139 140 |
# File 'lib/csv_decision/columns.rb', line 138 def defaults=(value) @dictionary.defaults = value end |
#dictionary ⇒ Hash{Symbol=>[false, Integer]}
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 Dictionary of all input and output column names.
144 145 146 |
# File 'lib/csv_decision/columns.rb', line 144 def dictionary @dictionary.columns end |
#ifs ⇒ Hash{Index=>Entry}
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.
if: columns hash keyed by column index.
162 163 164 |
# File 'lib/csv_decision/columns.rb', line 162 def ifs @dictionary.ifs end |
#input_keys ⇒ Array<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 All input column symbols.
173 174 175 |
# File 'lib/csv_decision/columns.rb', line 173 def input_keys @dictionary.columns.select { |_k, v| v == :in }.keys end |
#ins ⇒ Hash{Index=>Entry}
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.
Input columns hash keyed by column index.
150 151 152 |
# File 'lib/csv_decision/columns.rb', line 150 def ins @dictionary.ins end |
#outs ⇒ Hash{Index=>Entry}
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.
Output columns hash keyed by column index.
156 157 158 |
# File 'lib/csv_decision/columns.rb', line 156 def outs @dictionary&.outs end |
#paths ⇒ Hash{Index=>Entry}
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.
path: columns hash keyed by column index.
168 169 170 |
# File 'lib/csv_decision/columns.rb', line 168 def paths @dictionary.paths end |