Class: CSVDecision::Dictionary::Entry Private
- Inherits:
-
Object
- Object
- CSVDecision::Dictionary::Entry
- Defined in:
- lib/csv_decision/dictionary.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.
Column dictionary entries.
Instance Attribute Summary collapse
-
#eval ⇒ nil, Boolean
private
If set to true then this column has procs that need evaluating, otherwise it only contains constants.
-
#function ⇒ Matchers::Proc, Object
private
For a column of type set: gives the proc that must be evaluated to set the default value.
-
#indexed ⇒ Boolean
private
Returns true if this column is indexed.
-
#name ⇒ Symbol
readonly
private
Column name.
-
#set_if ⇒ nil, ...
readonly
private
Defined for columns of type :set, nil otherwise.
-
#type ⇒ Symbol
readonly
private
Column type.
Class Method Summary collapse
-
.create(name:, type:) ⇒ Entry
private
Create a new column dictionary entry defaulting attributes from the column type, which is looked up in the above table.
Instance Method Summary collapse
-
#initialize(name:, type:, eval: nil, set_if: nil, indexed: nil) ⇒ Entry
constructor
private
A new instance of Entry.
-
#ins? ⇒ Boolean
private
Return true is this is an input column, false otherwise.
-
#to_h ⇒ Hash{Symbol=>[nil, Boolean, Symbol]}
private
Convert the object’s attributes to a hash.
Constructor Details
#initialize(name:, type:, eval: nil, set_if: nil, indexed: nil) ⇒ 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.
Returns a new instance of Entry.
92 93 94 95 96 97 98 99 100 |
# 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 |
Instance Attribute Details
#eval ⇒ nil, Boolean
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 If set to true then this column has procs that need evaluating, otherwise it only contains constants.
76 77 78 |
# File 'lib/csv_decision/dictionary.rb', line 76 def eval @eval end |
#function ⇒ Matchers::Proc, 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.
Returns 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.
85 86 87 |
# File 'lib/csv_decision/dictionary.rb', line 85 def function @function end |
#indexed ⇒ Boolean
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 true if this column is indexed
72 73 74 |
# File 'lib/csv_decision/dictionary.rb', line 72 def indexed @indexed end |
#name ⇒ Symbol (readonly)
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 Column name.
66 67 68 |
# File 'lib/csv_decision/dictionary.rb', line 66 def name @name end |
#set_if ⇒ nil, ... (readonly)
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 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.
81 82 83 |
# File 'lib/csv_decision/dictionary.rb', line 81 def set_if @set_if end |
#type ⇒ Symbol (readonly)
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 Column type.
69 70 71 |
# File 'lib/csv_decision/dictionary.rb', line 69 def type @type end |
Class Method Details
.create(name:, type:) ⇒ 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.
Create a new column dictionary entry defaulting attributes from the column type, which is looked up in the above table.
51 52 53 54 55 56 57 58 |
# 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 |
Instance Method Details
#ins? ⇒ Boolean
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.
Return true is this is an input column, false otherwise.
61 62 63 |
# File 'lib/csv_decision/dictionary.rb', line 61 def ins? @ins end |
#to_h ⇒ Hash{Symbol=>[nil, Boolean, 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.
Convert the object’s attributes to a hash.
105 106 107 108 109 110 111 112 |
# File 'lib/csv_decision/dictionary.rb', line 105 def to_h { name: @name, type: @type, eval: @eval, set_if: @set_if } end |