Class: XlsFunction::UserDefinedFunctionFactory::ProcFunction

Inherits:
Evaluators::FunctionEvaluator show all
Defined in:
lib/xls_function/user_defined_function_factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from 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 Evaluators::ClassDictionary

included

Methods included from Evaluators::ErrorDetector

#class_info, #class_name, included, #rescue_with

Methods included from Evaluators::ArgumentsDefinable

included

Methods included from Evaluators::Evaluable

#evaluate, included

Constructor Details

#initialize(context, custom_proc) ⇒ ProcFunction

Returns a new instance of ProcFunction.



37
38
39
40
# File 'lib/xls_function/user_defined_function_factory.rb', line 37

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

Instance Attribute Details

#custom_procObject (readonly)

Returns the value of attribute custom_proc.



35
36
37
# File 'lib/xls_function/user_defined_function_factory.rb', line 35

def custom_proc
  @custom_proc
end

#evaled_arglistObject (readonly)

Returns the value of attribute evaled_arglist.



35
36
37
# File 'lib/xls_function/user_defined_function_factory.rb', line 35

def evaled_arglist
  @evaled_arglist
end

Instance Method Details

#evalObject



54
55
56
# File 'lib/xls_function/user_defined_function_factory.rb', line 54

def eval
  custom_proc.call(*evaled_arglist)
end

#eval_arglistObject



43
44
45
46
47
48
49
50
51
52
# File 'lib/xls_function/user_defined_function_factory.rb', line 43

def eval_arglist
  # There is no argument definition, so it evaluates as it is passed.
  @evaled_arglist = arg_list.map do |arg|
    value = evaluate_or_self(arg)
    detect_error(value)
    break if error?

    value
  end
end