Class: Janeway::AST::CurrentNode

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

Overview

CurrentNode addresses the current node of the filter-selector that is directly enclosing the identifier.

Note: Within nested filter-selectors, there is no syntax to address the current node of any other than the directly enclosing filter-selector (i.e., of filter-selectors enclosing the filter-selector that is directly enclosing the identifier).

It may be followed by another selector which is applied to it. Within the IETF examples, I see @ followed by these selectors:

* name selector (dot notation)
* filter selector (bracketed)
* wildcard selector

Probably best to assume that any selector type could appear here.

It may also not be followed by any selector, and be used directly with a comparison operator.

Construct accepts an optional Selector which will be applied to the "current" node

Examples:

$.a[?@.b == 'kilo']
$.a[?@.b]
$[?@.*]
$[?@[?@.b]]
$.a[?@<2 || @.b == "k"]
$.o[?@>1 && @<4]
$.a[?@ == @]

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

#empty?Boolean

True if this is a bare current node operator, without a following expression

Returns:



46
47
48
# File 'lib/janeway/ast/current_node.rb', line 46

def empty?
  @next.nil?
end

#singular_query?Boolean

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



40
41
42
# File 'lib/janeway/ast/current_node.rb', line 40

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

#to_sObject



32
33
34
# File 'lib/janeway/ast/current_node.rb', line 32

def to_s
  "@#{@next}"
end

#tree(level) ⇒ Array

Parameters:

  • level (Integer)

Returns:

  • (Array)


52
53
54
# File 'lib/janeway/ast/current_node.rb', line 52

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