Class: NodeQuery::Compiler::AttributeList

Inherits:
Object
  • Object
show all
Defined in:
lib/node_query/compiler/attribute_list.rb

Overview

AttributeList contains one or more Attribute.

Instance Method Summary collapse

Constructor Details

#initialize(attribute:, rest: nil) ⇒ AttributeList

Initialize an AttributeList.

Parameters:



9
10
11
12
# File 'lib/node_query/compiler/attribute_list.rb', line 9

def initialize(attribute:, rest: nil)
  @attribute = attribute
  @rest = rest
end

Instance Method Details

#match?(node, base_node) ⇒ Boolean

Check if the node matches the attribute list.

Parameters:

  • node (Node)

    the node

  • base_node (Node)

    the base node for evaluated value

Returns:



18
19
20
# File 'lib/node_query/compiler/attribute_list.rb', line 18

def match?(node, base_node)
  @attribute.match?(node, base_node) && (!@rest || @rest.match?(node, base_node))
end

#to_sObject



22
23
24
# File 'lib/node_query/compiler/attribute_list.rb', line 22

def to_s
  "[#{@attribute}]#{@rest}"
end