Class: Janeway::AST::RootNode

Inherits:
Expression show all
Defined in:
lib/janeway/ast/root_node.rb

Overview

Every JSONPath query (except those inside filter expressions; see Section 2.3.5) MUST begin with the root identifier $.

The root identifier $ represents the root node of the query argument and produces a nodelist consisting of that root node.

The root identifier may also be used in the filter selectors.

@example:

$(? $.key1 == $.key2 )

Instance Attribute Summary

Attributes inherited from Expression

#next, #value

Instance Method Summary collapse

Methods inherited from Expression

#chain_of?, #indented, #initialize, #literal?, #type, type_name

Constructor Details

This class inherits a constructor from Janeway::AST::Expression

Instance Method Details

#singular_query?Boolean

True if this is the root of a singular-query.



25
26
27
# File 'lib/janeway/ast/root_node.rb', line 25

def singular_query?
  chain_of?(AST::IndexSelector, AST::NameSelector)
end

#to_sObject



17
18
19
# File 'lib/janeway/ast/root_node.rb', line 17

def to_s
  "$#{@next}"
end

#tree(level = 0) ⇒ Array

Parameters:

  • level (Integer) (defaults to: 0)

Returns:

  • (Array)


31
32
33
# File 'lib/janeway/ast/root_node.rb', line 31

def tree(level = 0)
  [indented(level, '$'), @next&.tree(level + 1)]
end