Class: CSVDecision::Matchers::Proc Private

Inherits:
Array
  • Object
show all
Defined in:
lib/csv_decision/matchers.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.

Composite object for a data cell proc. Note that we do not need it to be comparable. Implemented as an immutable array of 2 or 3 entries for memory compactness and speed.

Instance Method Summary collapse

Constructor Details

#initialize(type:, function:, symbols: nil) ⇒ Proc

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 Proc

Parameters:

  • type (Symbol)

    Type of the function value - e.g., :constant or :guard.

  • function (Object)

    Either a lambda function, or some kind of constant such as an Integer.

  • symbols (nil, Symbol, Array<Symbol>)

    The symbol or list of symbols that the function uses to reference input hash keys (which are always symbolized).



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/csv_decision/matchers.rb', line 20

def initialize(type:, function:, symbols: nil)
  super()

  self << type

  # Function values should always be frozen
  self << function.freeze

  # Some function values, such as constants or 0-arity functions, do not reference symbols.
  self << symbols if symbols

  freeze
end

Instance Method Details

#functionObject

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 Either a lambda function, or some kind of constant such as an Integer.

Returns:

  • (Object)

    Either a lambda function, or some kind of constant such as an Integer.



40
41
42
# File 'lib/csv_decision/matchers.rb', line 40

def function
  fetch(1)
end

#symbolsnil, ...

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 The symbol or list of symbols that the function uses to reference input hash keys (which are always symbolized).

Returns:

  • (nil, Symbol, Array<Symbol>)

    The symbol or list of symbols that the function uses to reference input hash keys (which are always symbolized).



46
47
48
# File 'lib/csv_decision/matchers.rb', line 46

def symbols
  fetch(2, nil)
end

#typeSymbol

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 Type of the function value - e.g., :constant or :guard.

Returns:

  • (Symbol)

    Type of the function value - e.g., :constant or :guard.



35
36
37
# File 'lib/csv_decision/matchers.rb', line 35

def type
  fetch(0)
end