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.
309 310 311 |
# File 'lib/querly/pattern/expr.rb', line 309 def initialize(name:) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
307 308 309 |
# File 'lib/querly/pattern/expr.rb', line 307 def name @name end |
Instance Method Details
#=~(pair) ⇒ Object
313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/querly/pattern/expr.rb', line 313 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.type == :csend) && parent_node.children.first.equal?(node) test_node(node) end else test_node(node) end end |
#test_node(node) ⇒ Object
328 329 330 331 332 333 334 335 |
# File 'lib/querly/pattern/expr.rb', line 328 def test_node(node) case node&.type when :send, :csend node.children[1] == name when :lvar node.children.first == name end end |