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.
-
#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
ENTRYtable.
Instance Method Summary collapse
-
#initialize(name:, type:, eval: nil, set_if: 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) ⇒ 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.
70 71 72 73 74 75 76 77 |
# File 'lib/csv_decision/dictionary.rb', line 70 def initialize(name:, type:, eval: nil, set_if: nil) @name = name @type = type @eval = eval @set_if = set_if @function = nil @ins = INS_TYPES.member?(type) 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.
55 56 57 |
# File 'lib/csv_decision/dictionary.rb', line 55 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.
64 65 66 |
# File 'lib/csv_decision/dictionary.rb', line 64 def function @function 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.
48 49 50 |
# File 'lib/csv_decision/dictionary.rb', line 48 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.
60 61 62 |
# File 'lib/csv_decision/dictionary.rb', line 60 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.
51 52 53 |
# File 'lib/csv_decision/dictionary.rb', line 51 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 ENTRY table.
37 38 39 40 |
# File 'lib/csv_decision/dictionary.rb', line 37 def self.create(name:, type:) entry = ENTRY[type] new(name: name, eval: entry[:eval], type: entry[:type], set_if: entry[:set_if]) 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.
43 44 45 |
# File 'lib/csv_decision/dictionary.rb', line 43 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.
82 83 84 85 86 87 88 89 |
# File 'lib/csv_decision/dictionary.rb', line 82 def to_h { name: @name, type: @type, eval: @eval, set_if: @set_if } end |