Class: Mutant::AST::Pattern::Node Private

Inherits:
Mutant::AST::Pattern show all
Defined in:
lib/mutant/ast/pattern.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.

Defined Under Namespace

Classes: Attribute, Descendant

Constant Summary collapse

DEFAULTS =

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

{ attribute: nil, descendant: nil, variable: nil }.freeze

Instance Method Summary collapse

Methods inherited from Mutant::AST::Pattern

parse

Constructor Details

#initialize(attributes) ⇒ Node

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 Node.



19
20
21
# File 'lib/mutant/ast/pattern.rb', line 19

def initialize(attributes)
  super(DEFAULTS.merge(attributes))
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.

Descendant

Returns:

  • (Boolean)


77
78
79
80
81
82
83
# File 'lib/mutant/ast/pattern.rb', line 77

def match?(node)
  fail NotImplementedError if variable

  node.type.eql?(type) \
    && (!attribute || attribute.match?(node)) \
    && (!descendant || descendant.match?(node))
end

#syntaxObject

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.



85
86
87
# File 'lib/mutant/ast/pattern.rb', line 85

def syntax
  "#{type}#{pair_syntax}"
end