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.
249 250 251 |
# File 'lib/querly/pattern/expr.rb', line 249 def initialize(name:) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
247 248 249 |
# File 'lib/querly/pattern/expr.rb', line 247 def name @name end |
Instance Method Details
#=~(pair) ⇒ Object
253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/querly/pattern/expr.rb', line 253 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
268 269 270 271 272 273 274 275 276 277 |
# File 'lib/querly/pattern/expr.rb', line 268 def test_node(node) case node&.type when :send node.children[1] == name when :lvar node.children.first == name when :self name == :self end end |