Class: CSVDecision::Columns

Inherits:
Object
  • Object
show all
Defined in:
lib/csv_decision/columns.rb

Overview

Dictionary of all this table’s columns - inputs, outputs etc.

Defined Under Namespace

Classes: Dictionary, Entry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table) ⇒ Columns

Returns a new instance of Columns.

Parameters:

  • table (Table)

    Decision table being constructed.



65
66
67
68
69
70
71
72
73
74
# File 'lib/csv_decision/columns.rb', line 65

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 = Header.dictionary(row: row) if row

  freeze
end

Instance Attribute Details

#dictionaryObject (readonly)

Dictionary of all data columns



42
43
44
# File 'lib/csv_decision/columns.rb', line 42

def dictionary
  @dictionary
end

Instance Method Details

#insObject

Input columns



45
46
47
# File 'lib/csv_decision/columns.rb', line 45

def ins
  @dictionary.ins
end

#outsObject

Output columns



50
51
52
# File 'lib/csv_decision/columns.rb', line 50

def outs
  @dictionary.outs
end