Class: CSVDecision::Columns Private

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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.

Parameters:

  • table (Table)

    Decision table being constructed.



83
84
85
86
87
88
89
90
91
92
# File 'lib/csv_decision/columns.rb', line 83

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)

  # Build a dictionary of all valid data columns from the header row.
  @dictionary = CSVDecision::Dictionary.build(header: row, dictionary: Dictionary.new) if row

  freeze
end

Instance Method Details

#dictionaryObject

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.



64
65
66
# File 'lib/csv_decision/columns.rb', line 64

def dictionary
  @dictionary.columns
end

#ifsHash{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.

Returns:

  • (Hash{Index=>Entry})


60
61
62
# File 'lib/csv_decision/columns.rb', line 60

def ifs
  @dictionary.ifs
end

#input_keysObject

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.



68
69
70
# File 'lib/csv_decision/columns.rb', line 68

def input_keys
  @dictionary.columns.select { |_k, v| v == :in }.keys
end

#insHash{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.

Returns:

  • (Hash{Index=>Entry})


48
49
50
# File 'lib/csv_decision/columns.rb', line 48

def ins
  @dictionary.ins
end

#outsHash{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.

Returns:

  • (Hash{Index=>Entry})


54
55
56
# File 'lib/csv_decision/columns.rb', line 54

def outs
  @dictionary&.outs
end