Class: Solargraph::Pin::Method

Inherits:
Base
  • Object
show all
Defined in:
lib/solargraph/pin/method.rb

Direct Known Subclasses

Directed::Method

Instance Attribute Summary collapse

Attributes inherited from Base

#namespace, #node, #source

Instance Method Summary collapse

Methods inherited from Base

#docstring, #filename, #location, #signature, #value

Constructor Details

#initialize(source, node, namespace, scope, visibility) ⇒ Method

Returns a new instance of Method.



7
8
9
10
11
# File 'lib/solargraph/pin/method.rb', line 7

def initialize source, node, namespace, scope, visibility
  super(source, node, namespace)
  @scope = scope
  @visibility = visibility
end

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



4
5
6
# File 'lib/solargraph/pin/method.rb', line 4

def scope
  @scope
end

#visibilityObject (readonly)

Returns the value of attribute visibility.



5
6
7
# File 'lib/solargraph/pin/method.rb', line 5

def visibility
  @visibility
end

Instance Method Details

#kindObject



21
22
23
# File 'lib/solargraph/pin/method.rb', line 21

def kind
  Solargraph::Suggestion::METHOD
end

#nameObject



13
14
15
# File 'lib/solargraph/pin/method.rb', line 13

def name
  @name ||= "#{node.children[(node.type == :def ? 0 : 1)]}"
end

#parametersObject



33
34
35
# File 'lib/solargraph/pin/method.rb', line 33

def parameters
  @parameters ||= get_method_args
end

#pathObject



17
18
19
# File 'lib/solargraph/pin/method.rb', line 17

def path
  @path ||= namespace + (scope == :instance ? '#' : '.') + name
end

#return_typeObject



25
26
27
28
29
30
31
# File 'lib/solargraph/pin/method.rb', line 25

def return_type
  if @return_type.nil? and !docstring.nil?
    tag = docstring.tag(:return)
    @return_type = tag.types[0] unless tag.nil?
  end
  @return_type
end