Module: JMESPath::Nodes::NumberComparator Private
- Includes:
- TypeChecker
- Included in:
- MaxByFunction, MinByFunction
- Defined in:
- lib/jmespath/nodes/function.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Constant Summary
Constants included from TypeChecker
TypeChecker::ARRAY_TYPE, TypeChecker::BOOLEAN_TYPE, TypeChecker::EXPRESSION_TYPE, TypeChecker::NULL_TYPE, TypeChecker::NUMBER_TYPE, TypeChecker::OBJECT_TYPE, TypeChecker::STRING_TYPE, TypeChecker::TYPE_NAMES
Instance Method Summary collapse
Methods included from TypeChecker
Instance Method Details
#number_compare(mode, *args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
# File 'lib/jmespath/nodes/function.rb', line 422 def number_compare(mode, *args) if args.count == 2 values = args[0] expression = args[1] if get_type(values) == ARRAY_TYPE && get_type(expression) == EXPRESSION_TYPE values.send(mode) do |entry| value = expression.eval(entry) if get_type(value) == NUMBER_TYPE value else raise Errors::InvalidTypeError, "function #{mode}() expects values to be an numbers" end end else raise Errors::InvalidTypeError, "function #{mode}() expects an array and an expression" end else raise Errors::InvalidArityError, "function #{mode}() expects two arguments" end end |