Class: CSVDecision::Dictionary::Entry Private

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#evalnil, 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.

Returns:

  • (nil, Boolean)

    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

#functionMatchers::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.

Returns:

  • (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.



64
65
66
# File 'lib/csv_decision/dictionary.rb', line 64

def function
  @function
end

#nameSymbol (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.

Returns:

  • (Symbol)

    Column name.



48
49
50
# File 'lib/csv_decision/dictionary.rb', line 48

def name
  @name
end

#set_ifnil, ... (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.

Returns:

  • (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.



60
61
62
# File 'lib/csv_decision/dictionary.rb', line 60

def set_if
  @set_if
end

#typeSymbol (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.

Returns:

  • (Symbol)

    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.

Parameters:

  • name (Symbol)

    Column name.

  • type (Symbol)

    Column type.

Returns:

  • (Entry)

    Column dictionary entry.



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.

Returns:

  • (Boolean)

    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_hHash{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.

Returns:

  • (Hash{Symbol=>[nil, Boolean, Symbol]})


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