Class: Janeway::AST::CurrentNode
- Inherits:
-
Expression
- Object
- Expression
- Janeway::AST::CurrentNode
- 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
Instance Attribute Summary collapse
-
#next ⇒ Object
Subsequent expression that modifies the output of this expression.
Attributes inherited from Expression
Instance Method Summary collapse
-
#empty? ⇒ Boolean
True if this is a bare current node operator, without a following expression.
-
#singular_query? ⇒ Boolean
True if this is the root of a singular-query.
- #to_s ⇒ Object
- #tree(level) ⇒ 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
33 34 35 |
# File 'lib/janeway/ast/current_node.rb', line 33 def next @next end |
Instance Method Details
#empty? ⇒ Boolean
True if this is a bare current node operator, without a following expression
59 60 61 |
# File 'lib/janeway/ast/current_node.rb', line 59 def empty? @next.nil? end |
#singular_query? ⇒ Boolean
True if this is the root of a singular-query.
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/janeway/ast/current_node.rb', line 43 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
35 36 37 |
# File 'lib/janeway/ast/current_node.rb', line 35 def to_s "@#{@next}" end |
#tree(level) ⇒ Array
65 66 67 |
# File 'lib/janeway/ast/current_node.rb', line 65 def tree(level) [indented(level, '@'), @next.tree(indent + 1)] end |