Class: NodeQuery::Compiler::ExpressionList
- Inherits:
-
Object
- Object
- NodeQuery::Compiler::ExpressionList
- Defined in:
- lib/node_query/compiler/expression_list.rb
Overview
ExpressionList contains one or more Expression.
Instance Method Summary collapse
-
#initialize(expression:, rest: nil) ⇒ ExpressionList
constructor
Initialize an ExpressionList.
-
#match_node?(node) ⇒ Boolean
Check if the node matches the expression list.
-
#query_nodes(node, options = {}) ⇒ Array<Node>
Query nodes by the current and the rest expression.
- #to_s ⇒ Object
Constructor Details
#initialize(expression:, rest: nil) ⇒ ExpressionList
Initialize an ExpressionList.
9 10 11 12 |
# File 'lib/node_query/compiler/expression_list.rb', line 9 def initialize(expression:, rest: nil) @expression = expression @rest = rest end |
Instance Method Details
#match_node?(node) ⇒ Boolean
Check if the node matches the expression list.
31 32 33 |
# File 'lib/node_query/compiler/expression_list.rb', line 31 def match_node?(node) !query_nodes(node).empty? end |
#query_nodes(node, options = {}) ⇒ Array<Node>
Query nodes by the current and the rest expression.
21 22 23 24 25 26 |
# File 'lib/node_query/compiler/expression_list.rb', line 21 def query_nodes(node, = {}) matching_nodes = @expression.query_nodes(node, ) return matching_nodes if @rest.nil? matching_nodes + @rest.query_nodes(node, ) end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/node_query/compiler/expression_list.rb', line 35 def to_s [@expression, @rest].compact.join(', ') end |