Class: Querly::Pattern::Expr::ReceiverContext

Inherits:
Base
  • Object
show all
Defined in:
lib/querly/pattern/expr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, #=~, #attributes

Constructor Details

#initialize(receiver:) ⇒ ReceiverContext

Returns a new instance of ReceiverContext.



285
286
287
# File 'lib/querly/pattern/expr.rb', line 285

def initialize(receiver:)
  @receiver = receiver
end

Instance Attribute Details

#receiverObject (readonly)

Returns the value of attribute receiver.



283
284
285
# File 'lib/querly/pattern/expr.rb', line 283

def receiver
  @receiver
end

Instance Method Details

#test_node(node) ⇒ Object



289
290
291
292
293
294
295
# File 'lib/querly/pattern/expr.rb', line 289

def test_node(node)
  if receiver.test_node(node)
    true
  else
    node&.type == :send && test_node(node.children[0])
  end
end