Class: Fast::Parent

Inherits:
Find
  • Object
show all
Defined in:
lib/fast.rb

Overview

Sometimes you want to check some children but get the parent element, for such cases, parent can be useful. Example: You’re searching for ‘int` usages in your code. But you don’t want to check the integer itself, but who is using it: ‘^^(int _)` will give you the variable being assigned or the expression being used.

Instance Attribute Summary

Attributes inherited from Find

#token

Instance Method Summary collapse

Methods inherited from Find

#==, #compare_symbol_or_head, #debug, #debug_match_recursive, #initialize, #match_recursive

Constructor Details

This class inherits a constructor from Fast::Find

Instance Method Details

#match?(node) ⇒ Boolean

Returns:

  • (Boolean)


653
654
655
# File 'lib/fast.rb', line 653

def match?(node)
  node.each_child_node.any?(&method(:match_node))
end

#match_nodeObject



652
# File 'lib/fast.rb', line 652

alias match_node match?

#to_sObject



657
658
659
# File 'lib/fast.rb', line 657

def to_s
  "^#{token}"
end