Class: CallSearcher::MethodCall
- Inherits:
-
Object
- Object
- CallSearcher::MethodCall
- Defined in:
- lib/call_searcher/method_call.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #github_url ⇒ Object
-
#initialize(node:, context:) ⇒ MethodCall
constructor
A new instance of MethodCall.
- #inspect ⇒ Object
- #location ⇒ Object
- #mid ⇒ Object
- #receiver ⇒ Object
- #relative_path ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(node:, context:) ⇒ MethodCall
Returns a new instance of MethodCall.
9 10 11 12 |
# File 'lib/call_searcher/method_call.rb', line 9 def initialize(node:, context:) @node = node @context = context end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
7 8 9 |
# File 'lib/call_searcher/method_call.rb', line 7 def node @node end |
Instance Method Details
#github_url ⇒ Object
44 45 46 47 48 |
# 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 ⇒ Object
40 41 42 |
# File 'lib/call_searcher/method_call.rb', line 40 def inspect "<#{self.class} #{type}@#{location}>" end |
#location ⇒ Object
36 37 38 |
# File 'lib/call_searcher/method_call.rb', line 36 def location "#{@context.path}:#{@node.first_lineno}" end |
#mid ⇒ Object
27 28 29 30 31 32 33 34 |
# 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 ⇒ Object
18 19 20 21 22 23 24 25 |
# 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 ⇒ Object
50 51 52 |
# 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 ⇒ Object
14 15 16 |
# File 'lib/call_searcher/method_call.rb', line 14 def type @type ||= node.type end |