Class: Janeway::AST::RootNode
- Inherits:
-
Expression
- Object
- Expression
- Janeway::AST::RootNode
- 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 collapse
-
#next ⇒ Object
Subsequent expression that modifies the output of this expression.
Attributes inherited from Expression
Instance Method Summary collapse
-
#singular_query? ⇒ Boolean
True if this is the root of a singular-query.
- #to_s ⇒ Object
- #tree(level = 0) ⇒ Array
Methods inherited from Expression
#indented, #initialize, #literal?, #type
Constructor Details
This class inherits a constructor from Janeway::AST::Expression
Instance Attribute Details
#next ⇒ Object
Subsequent expression that modifies the output of this expression
18 19 20 |
# File 'lib/janeway/ast/root_node.rb', line 18 def next @next end |
Instance Method Details
#singular_query? ⇒ Boolean
True if this is the root of a singular-query.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/janeway/ast/root_node.rb', line 28 def singular_query? return true unless @next # there are no following selectors selector_types = [] selector = @next loop do selector_types << selector.class selector = selector&.next break unless selector end allowed = [AST::IndexSelector, AST::NameSelector] selector_types.uniq.all? { allowed.include?(_1) } end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/janeway/ast/root_node.rb', line 20 def to_s "$#{@next}" end |
#tree(level = 0) ⇒ Array
44 45 46 |
# File 'lib/janeway/ast/root_node.rb', line 44 def tree(level = 0) [indented(level, '$'), @next.tree(level + 1)] end |