Class: Evilution::AST::Pattern::NodeMatcher
- Inherits:
-
Object
- Object
- Evilution::AST::Pattern::NodeMatcher
- Defined in:
- lib/evilution/ast/pattern/matcher.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#node_type ⇒ Object
readonly
Returns the value of attribute node_type.
Instance Method Summary collapse
-
#initialize(node_type, attributes) ⇒ NodeMatcher
constructor
A new instance of NodeMatcher.
- #match?(node) ⇒ Boolean
Constructor Details
#initialize(node_type, attributes) ⇒ NodeMatcher
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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
7 8 9 |
# File 'lib/evilution/ast/pattern/matcher.rb', line 7 def attributes @attributes end |
#node_type ⇒ Object (readonly)
Returns the value of attribute node_type.
7 8 9 |
# File 'lib/evilution/ast/pattern/matcher.rb', line 7 def node_type @node_type end |
Instance Method Details
#match?(node) ⇒ 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 |