Class: XlsFunction::Evaluators::Functions::Rept

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

Instance Method Summary collapse

Methods inherited from XlsFunction::Evaluators::FunctionEvaluator

#arg_list, #before_eval, #convert_to, create, #detect_error, #error?, #error_message, #eval_arglist, #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



10
11
12
13
14
15
16
# File 'lib/xls_function/evaluators/functions/rept.rb', line 10

def eval
  number_times_i = number_times.to_i
  return ::XlsFunction::ErrorValue.value!(number_times_is_negative) if number_times_i.negative?
  return '' if number_times_i.zero?

  source * number_times_i
end

#number_times_is_negativeObject



18
19
20
21
# File 'lib/xls_function/evaluators/functions/rept.rb', line 18

def number_times_is_negative
  message = error_message(:number_is_negative, label: 'number_times', number: number_times)
  class_info(message)
end