lib/csv_decision/columns.rb in csv_decision-0.0.9 vs lib/csv_decision/columns.rb in csv_decision-0.1.0

- old
+ new

@@ -13,56 +13,61 @@ # Dictionary of all data columns. # The key of each hash is the header cell's array column index. # Note that input and output columns can be interspersed and need not have unique names. class Dictionary - # Input columns. + # @return [Hash{Integer=>Entry}] All column names. + attr_accessor :columns + # @return [Hash{Integer=>Entry}] All input column dictionary entries. attr_accessor :ins - # Output columns. # @return [Hash{Integer=>Entry}] All output column dictionary entries. attr_accessor :outs - # if: columns. # @return [Hash{Integer=>Entry}] All if: column dictionary entries. attr_accessor :ifs # TODO: Input hash path - optional (planned feature) # attr_accessor :path # TODO: Input columns with a default value (planned feature) # attr_accessor :defaults def initialize + @columns = {} + @ifs = {} @ins = {} @outs = {} - @ifs = {} # TODO: @path = {} # TODO: @defaults = {} end end - # Dictionary of all data columns. - # @return [Columns::Dictionary] - attr_reader :dictionary - # Input columns hash keyed by column index. # @return [Hash{Index=>Entry}] def ins @dictionary.ins end # Output columns hash keyed by column index. # @return [Hash{Index=>Entry}] def outs - @dictionary.outs + @dictionary&.outs end # if: columns hash keyed by column index. # @return [Hash{Index=>Entry}] def ifs @dictionary.ifs + end + + def dictionary + @dictionary.columns + end + + def input_keys + @dictionary.columns.select { |_k, v| v == :in }.keys end # Input columns with defaults specified (planned feature) # def defaults # @dictionary.defaults \ No newline at end of file