Class: NodeQuery::Compiler::AttributeList
- Inherits:
-
Object
- Object
- NodeQuery::Compiler::AttributeList
- Defined in:
- lib/node_query/compiler/attribute_list.rb
Overview
AttributeList contains one or more Attribute.
Instance Method Summary collapse
-
#initialize(attribute:, rest: nil) ⇒ AttributeList
constructor
Initialize an AttributeList.
-
#match?(node, base_node) ⇒ Boolean
Check if the node matches the attribute list.
- #to_s ⇒ Object
Constructor Details
#initialize(attribute:, rest: nil) ⇒ AttributeList
Initialize an AttributeList.
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.
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_s ⇒ Object
22 23 24 |
# File 'lib/node_query/compiler/attribute_list.rb', line 22 def to_s "[#{@attribute}]#{@rest}" end |