class CallSearcher::MethodCall

Attributes

node[R]

Public Class Methods

new(node:, context:) click to toggle source
# File lib/call_searcher/method_call.rb, line 9
def initialize(node:, context:)
  @node = node
  @context = context
end

Public Instance Methods

github_url() click to toggle source
# File lib/call_searcher/method_call.rb, line 44
def github_url
  if @context.github
    "https://github.com/#{@context.github}/blob/master/#{relative_path}#L#{@node.first_lineno}"
  end
end
inspect() click to toggle source
# File lib/call_searcher/method_call.rb, line 40
def inspect
  "<#{self.class} #{type}@#{location}>"
end
location() click to toggle source
# File lib/call_searcher/method_call.rb, line 36
def location
  "#{@context.path}:#{@node.first_lineno}"
end
mid() click to toggle source
# File lib/call_searcher/method_call.rb, line 27
def mid
  case type
  when :FCALL, :VCALL
    node.children[0]
  else
    node.children[1]
  end
end
receiver() click to toggle source
# File lib/call_searcher/method_call.rb, line 18
def receiver
  case type
  when :FCALL, :VCALL
    nil
  else
    node.children[0]
  end
end
relative_path() click to toggle source
# File lib/call_searcher/method_call.rb, line 50
def relative_path
  Pathname.new(@context.path).relative_path_from(Pathname.new(@context.root_dir))
end
type() click to toggle source
# File lib/call_searcher/method_call.rb, line 14
def type
  @type ||= node.type
end