Class: Evilution::AST::Pattern::NodeMatcher Private

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/ast/pattern/matcher.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node_type, attributes) ⇒ NodeMatcher

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of NodeMatcher.



9
10
11
12
13
# File 'lib/evilution/ast/pattern/matcher.rb', line 9

def initialize(node_type, attributes)
  @node_type = node_type
  @prism_class = resolve_prism_class(node_type)
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
# File 'lib/evilution/ast/pattern/matcher.rb', line 7

def attributes
  @attributes
end

#node_typeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
# File 'lib/evilution/ast/pattern/matcher.rb', line 7

def node_type
  @node_type
end

Instance Method Details

#match?(node) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/evilution/ast/pattern/matcher.rb', line 15

def match?(node)
  return false unless node.is_a?(@prism_class)

  @attributes.all? { |attr_name, value_matcher| match_attribute?(node, attr_name, value_matcher) }
end