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

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

Defined Under Namespace

Classes: Function

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, #initialize, #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

This class inherits a constructor from XlsFunction::Evaluators::FunctionEvaluator

Instance Method Details

#evalObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/xls_function/evaluators/functions/lambda.rb', line 11

def eval
  # arguments at lambda
  # the last one is calculation
  calculation = arg_list.pop
  # returns as anonymous class
  klass = Class.new(Function)

  klass.define_singleton_method(:create) do |context|
    klass.new(context, calculation)
  end

  # define variant as argument
  arg_list.each do |variant|
    klass.define_arg variant.name.to_sym
  end

  klass
end

#eval_arglistObject



7
8
9
# File 'lib/xls_function/evaluators/functions/lambda.rb', line 7

def eval_arglist
  # Skip common argument evaluation and assignment
end