Class: XlsFunction::Evaluators::Functions::Lambda::Function

Inherits:
XlsFunction::Evaluators::FunctionEvaluator show all
Defined in:
lib/xls_function/evaluators/functions/lambda.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from XlsFunction::Evaluators::FunctionEvaluator

#arg_list, #before_eval, #convert_to, create, #detect_error, #error?, #error_message, #eval_or_map_eval, #evaluate, #evaluate_or_self, #map_eval, to_h, #to_proc, to_proc, translated_description, #variant_context

Methods included from ClassDictionary

included

Methods included from ErrorDetector

#class_info, #class_name, included, #rescue_with

Methods included from ArgumentsDefinable

included

Methods included from Evaluable

#evaluate, included

Constructor Details

#initialize(context, calculation) ⇒ Function

Returns a new instance of Function.



34
35
36
37
# File 'lib/xls_function/evaluators/functions/lambda.rb', line 34

def initialize(context, calculation)
  super(context)
  @calculation = calculation
end

Instance Attribute Details

#calculationObject (readonly)

use in lambda



32
33
34
# File 'lib/xls_function/evaluators/functions/lambda.rb', line 32

def calculation
  @calculation
end

Instance Method Details

#evalObject



49
50
51
52
# File 'lib/xls_function/evaluators/functions/lambda.rb', line 49

def eval
  # run with composed context
  calculation.evaluate(context)
end

#eval_arglistObject



39
40
41
42
43
44
45
46
47
# File 'lib/xls_function/evaluators/functions/lambda.rb', line 39

def eval_arglist
  super
  return if error?

  # set to variant
  self.class.arg_definitions.each do |name, _default, _type|
    variant_context[name.to_s] = instance_variable_get("@#{name}")
  end
end