Class: JMESPath::Nodes::StartsWithFunction Private
- Includes:
- TypeChecker
- Defined in:
- lib/jmespath/nodes/function.rb
This class is part of a private API. You should avoid using this class 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
Constants inherited from Function
Instance Method Summary collapse
- #call(args) ⇒ Object private
Methods included from TypeChecker
Methods inherited from Function
create, #initialize, #optimize, #visit
Methods inherited from Node
#chains_with?, #hash_like?, #optimize, #visit
Constructor Details
This class inherits a constructor from JMESPath::Nodes::Function
Instance Method Details
#call(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.
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
# File 'lib/jmespath/nodes/function.rb', line 529 def call(args) if args.count == 2 search, prefix = args search_type = get_type(search) prefix_type = get_type(prefix) if search_type != STRING_TYPE msg = "function starts_with() expects first argument to be a string" raise Errors::InvalidTypeError, msg end if prefix_type != STRING_TYPE msg = "function starts_with() expects second argument to be a string" raise Errors::InvalidTypeError, msg end search.start_with?(prefix) else msg = "function starts_with() expects two arguments" raise Errors::InvalidArityError, msg end end |