Module: XlsFunction
- Defined in:
- lib/xls_function.rb,
lib/xls_function/error.rb,
lib/xls_function/parser.rb,
lib/xls_function/version.rb,
lib/xls_function/converter.rb,
lib/xls_function/transform.rb,
lib/xls_function/format_string.rb,
lib/xls_function/default_logger.rb,
lib/xls_function/class_dictionary.rb,
lib/xls_function/parse_rules/common.rb,
lib/xls_function/evaluators/evaluable.rb,
lib/xls_function/format_string/parser.rb,
lib/xls_function/evaluators/functions/if.rb,
lib/xls_function/evaluators/functions/or.rb,
lib/xls_function/format_string/transform.rb,
lib/xls_function/evaluators/functions/abs.rb,
lib/xls_function/evaluators/functions/and.rb,
lib/xls_function/evaluators/functions/asc.rb,
lib/xls_function/evaluators/functions/day.rb,
lib/xls_function/evaluators/functions/ifs.rb,
lib/xls_function/evaluators/functions/int.rb,
lib/xls_function/evaluators/functions/len.rb,
lib/xls_function/evaluators/functions/let.rb,
lib/xls_function/evaluators/functions/mid.rb,
lib/xls_function/evaluators/functions/not.rb,
lib/xls_function/evaluators/functions/now.rb,
lib/xls_function/converters/date_converter.rb,
lib/xls_function/converters/time_converter.rb,
lib/xls_function/evaluators/error_detector.rb,
lib/xls_function/evaluators/functions/char.rb,
lib/xls_function/evaluators/functions/code.rb,
lib/xls_function/evaluators/functions/date.rb,
lib/xls_function/evaluators/functions/dbcs.rb,
lib/xls_function/evaluators/functions/find.rb,
lib/xls_function/evaluators/functions/hour.rb,
lib/xls_function/evaluators/functions/left.rb,
lib/xls_function/evaluators/functions/rept.rb,
lib/xls_function/evaluators/functions/sign.rb,
lib/xls_function/evaluators/functions/sqrt.rb,
lib/xls_function/evaluators/functions/text.rb,
lib/xls_function/evaluators/functions/time.rb,
lib/xls_function/evaluators/functions/trim.rb,
lib/xls_function/evaluators/functions/year.rb,
lib/xls_function/evaluators/true_evaluator.rb,
lib/xls_function/extensions/date_extension.rb,
lib/xls_function/extensions/hash_extension.rb,
lib/xls_function/extensions/time_extension.rb,
lib/xls_function/evaluators/false_evaluator.rb,
lib/xls_function/evaluators/functions/clean.rb,
lib/xls_function/evaluators/functions/exact.rb,
lib/xls_function/evaluators/functions/fixed.rb,
lib/xls_function/evaluators/functions/lower.rb,
lib/xls_function/evaluators/functions/month.rb,
lib/xls_function/evaluators/functions/power.rb,
lib/xls_function/evaluators/functions/right.rb,
lib/xls_function/evaluators/functions/round.rb,
lib/xls_function/evaluators/functions/today.rb,
lib/xls_function/evaluators/functions/trunc.rb,
lib/xls_function/evaluators/functions/upper.rb,
lib/xls_function/evaluators/functions/value.rb,
lib/xls_function/extensions/array_extension.rb,
lib/xls_function/converters/number_converter.rb,
lib/xls_function/evaluators/class_dictionary.rb,
lib/xls_function/evaluators/functions/concat.rb,
lib/xls_function/evaluators/functions/e_date.rb,
lib/xls_function/evaluators/functions/lambda.rb,
lib/xls_function/evaluators/functions/minute.rb,
lib/xls_function/evaluators/functions/proper.rb,
lib/xls_function/evaluators/functions/second.rb,
lib/xls_function/evaluators/functions/switch.rb,
lib/xls_function/evaluators/number_evaluator.rb,
lib/xls_function/evaluators/string_evaluator.rb,
lib/xls_function/evaluators/functions/iserror.rb,
lib/xls_function/evaluators/functions/replace.rb,
lib/xls_function/evaluators/functions/unichar.rb,
lib/xls_function/evaluators/functions/unicode.rb,
lib/xls_function/evaluators/variant_evaluator.rb,
lib/xls_function/parse_rules/binary_operation.rb,
lib/xls_function/evaluators/function_evaluator.rb,
lib/xls_function/evaluators/functions/isnumber.rb,
lib/xls_function/evaluators/functions/round_up.rb,
lib/xls_function/user_defined_function_factory.rb,
lib/xls_function/evaluators/arguments_definable.rb,
lib/xls_function/evaluators/functions/e_o_month.rb,
lib/xls_function/evaluators/functions/timevalue.rb,
lib/xls_function/evaluators/functions/date_value.rb,
lib/xls_function/evaluators/functions/round_down.rb,
lib/xls_function/evaluators/functions/substitute.rb,
lib/xls_function/format_string/parse_rules/dates.rb,
lib/xls_function/format_string/parse_rules/texts.rb,
lib/xls_function/format_string/parse_rules/times.rb,
lib/xls_function/converters/date_serial_converter.rb,
lib/xls_function/converters/time_serial_converter.rb,
lib/xls_function/evaluators/binary_operations/add.rb,
lib/xls_function/extensions/big_decimal_extension.rb,
lib/xls_function/transform_rules/number_transform.rb,
lib/xls_function/transform_rules/string_transform.rb,
lib/xls_function/format_string/parse_rules/numbers.rb,
lib/xls_function/transform_rules/boolean_transform.rb,
lib/xls_function/transform_rules/variant_transform.rb,
lib/xls_function/evaluators/binary_operations/equal.rb,
lib/xls_function/evaluators/binary_operations/power.rb,
lib/xls_function/evaluators/binary_operations/concat.rb,
lib/xls_function/evaluators/binary_operations/divide.rb,
lib/xls_function/format_string/transform_rules/dates.rb,
lib/xls_function/format_string/transform_rules/texts.rb,
lib/xls_function/format_string/transform_rules/times.rb,
lib/xls_function/evaluators/binary_operation_evaluator.rb,
lib/xls_function/evaluators/binary_operations/multiple.rb,
lib/xls_function/evaluators/binary_operations/subtract.rb,
lib/xls_function/format_string/transform_rules/numbers.rb,
lib/xls_function/evaluators/binary_operations/less_than.rb,
lib/xls_function/evaluators/binary_operations/not_equal.rb,
lib/xls_function/format_string/evaluators/time_evaluator.rb,
lib/xls_function/transform_rules/function_call_transform.rb,
lib/xls_function/evaluators/binary_operations/greater_than.rb,
lib/xls_function/format_string/evaluators/number_evaluator.rb,
lib/xls_function/transform_rules/binary_operation_transform.rb,
lib/xls_function/format_string/evaluators/elapsed_time_evaluator.rb,
lib/xls_function/evaluators/binary_operations/less_than_or_equal_to.rb,
lib/xls_function/evaluators/binary_operations/greater_than_or_equal_to.rb
Defined Under Namespace
Modules: Converter, Converters, Evaluators, Extensions, FormatString, ParseRules, TransformRules, UserDefinedFunctionFactory
Classes: DefaultLogger, Error, ErrorValue, EvaluationError, Parser, Transform
Constant Summary
collapse
- ERROR_VALUE =
'#VALUE!'.freeze
- ERROR_NUM =
'#NUM!'.freeze
- ERROR_NA =
'#N/A'.freeze
- ERROR_DIV0 =
'#DIV/0!'.freeze
- ERRORS =
[
ERROR_VALUE,
ERROR_NUM,
ERROR_NA
].freeze
- VERSION =
'0.1.7'.freeze
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.verbose ⇒ Object
Returns the value of attribute verbose.
57
58
59
|
# File 'lib/xls_function.rb', line 57
def verbose
@verbose
end
|
Class Method Details
.class_dictionary ⇒ Object
3
4
5
|
# File 'lib/xls_function/class_dictionary.rb', line 3
def class_dictionary
@class_dictionary ||= {}
end
|
.current_locale ⇒ Object
73
74
75
|
# File 'lib/xls_function.rb', line 73
def current_locale
I18n.locale
end
|
.evaluate(source, **context) ⇒ Object
31
32
33
34
35
|
# File 'lib/xls_function.rb', line 31
def evaluate(source, **context)
parsed = parser.parse(source.to_s.strip)
transformed = transform.apply(parsed, context)
transformed.evaluate
end
|
.functions ⇒ Object
77
78
79
80
|
# File 'lib/xls_function.rb', line 77
def functions
dictionaries = class_dictionary.reject { |_, v| v < XlsFunction::Evaluators::BinaryOperationEvaluator }
dictionaries.to_h { |identifier, klass| [identifier.to_s.upcase, klass.to_h] }
end
|
.locale=(value) ⇒ Object
69
70
71
|
# File 'lib/xls_function.rb', line 69
def locale=(value)
I18n.locale = value
end
|
.logger=(obj) ⇒ Object
63
64
65
66
67
|
# File 'lib/xls_function.rb', line 63
def logger=(obj)
raise 'Logger must respond_to :write' unless obj.respond_to?(:write)
@logger = obj
end
|
.parser ⇒ Object
37
38
39
40
41
|
# File 'lib/xls_function.rb', line 37
def parser
return @parser_factory.call if @parser_factory
XlsFunction::Parser.new
end
|
47
48
49
50
51
|
# File 'lib/xls_function.rb', line 47
def transform
return @transform_factory.call if @transform_factory
XlsFunction::Transform.new
end
|
.use_parser_factory(&block) ⇒ Object
43
44
45
|
# File 'lib/xls_function.rb', line 43
def use_parser_factory(&block)
@parser_factory = block
end
|
53
54
55
|
# File 'lib/xls_function.rb', line 53
def use_transform_factory(&block)
@transform_factory = block
end
|