class Querly::Pattern::Expr::Constant
Attributes
path[R]
Public Class Methods
new(path:)
click to toggle source
# File lib/querly/pattern/expr.rb, line 45 def initialize(path:) @path = path end
Public Instance Methods
test_constant(node, path)
click to toggle source
# File lib/querly/pattern/expr.rb, line 57 def test_constant(node, path) if node case node.type when :const parent = node.children[0] name = node.children[1] if name == path.last path.count == 1 || test_constant(parent, path.take(path.count - 1)) end when :cbase path.empty? end else path.empty? end end
test_node(node)
click to toggle source
# File lib/querly/pattern/expr.rb, line 49 def test_node(node) if path test_constant node, path else node&.type == :const end end