Class: Querly::Pattern::Expr::Vcall
- Defined in:
- lib/querly/pattern/expr.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #=~(pair) ⇒ Object
-
#initialize(name:) ⇒ Vcall
constructor
A new instance of Vcall.
- #test_node(node) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(name:) ⇒ Vcall
Returns a new instance of Vcall.
302 303 304 |
# File 'lib/querly/pattern/expr.rb', line 302 def initialize(name:) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
300 301 302 |
# File 'lib/querly/pattern/expr.rb', line 300 def name @name end |
Instance Method Details
#=~(pair) ⇒ Object
306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/querly/pattern/expr.rb', line 306 def =~(pair) node = pair.node if node.type == :lvar # We don't want lvar without method call # Skips when the node is not receiver of :send parent_node = pair.parent&.node if parent_node && parent_node.type == :send && parent_node.children.first.equal?(node) test_node(node) end else test_node(node) end end |
#test_node(node) ⇒ Object
321 322 323 324 325 326 327 328 |
# File 'lib/querly/pattern/expr.rb', line 321 def test_node(node) case node&.type when :send node.children[1] == name when :lvar node.children.first == name end end |