Class: Synvert::Core::NodeQuery::Compiler::AttributeList

Inherits:
Object
  • Object
show all
Defined in:
lib/synvert/core/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 a AttributeList.

Parameters:



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

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

Instance Method Details

#match?(node) ⇒ Boolean

Check if the node matches the attribute list.

Returns:



16
17
18
# File 'lib/synvert/core/node_query/compiler/attribute_list.rb', line 16

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

#to_sObject



20
21
22
# File 'lib/synvert/core/node_query/compiler/attribute_list.rb', line 20

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