class CSVDecision::Dictionary::Entry
Column dictionary entries.
Constants
Attributes
@return [nil, Boolean] If set to true then this column has procs that
need evaluating, otherwise it only contains constants.
@return [Matchers::Proc, Object] For a column of type set: gives the proc that must be
evaluated to set the default value. If not a proc, then it's some type of constant.
@return [Boolean] Returns true if this column is indexed
@return [Symbol] Column name.
@return [nil, true, Symbol] Defined for columns of type :set, nil otherwise.
If true, then default is set unconditionally, otherwise the method symbol sent to the input hash value that must evaluate to a truthy value.
@return [Symbol] Column type.
Public Class Methods
Create a new column dictionary entry defaulting attributes from the column type, which is looked up in the above table.
@param name [Symbol] Column name. @param type [Symbol] Column type. @return [Entry] Column dictionary entry.
# File lib/csv_decision/dictionary.rb, line 51 def self.create(name:, type:) entry = ENTRY[type] new(name: name, eval: entry[:eval], # Set if the column requires functions evaluated type: entry[:type], # Column type set_if: entry[:set_if], # Set if the column has a conditional default indexed: entry[:type] != :guard) # A guard column cannot be indexed. end
@param name (see name
) @param type (see type
) @param eval (see eval
) @param set_if
(see set_if
) @param indexed (see indexed
)
# File lib/csv_decision/dictionary.rb, line 92 def initialize(name:, type:, eval: nil, set_if: nil, indexed: nil) @name = name @type = type @eval = eval @set_if = set_if @function = nil @ins = INS_TYPES.member?(type) @indexed = indexed end
Public Instance Methods
@return [Boolean] Return true is this is an input column, false otherwise.
# File lib/csv_decision/dictionary.rb, line 61 def ins? @ins end
Convert the object's attributes to a hash.
@return [Hash{Symbol=>[nil, Boolean, Symbol]}]
# File lib/csv_decision/dictionary.rb, line 105 def to_h { name: @name, type: @type, eval: @eval, set_if: @set_if } end