Class: Solargraph::Pin::Attribute

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

Direct Known Subclasses

Directed::Attribute

Instance Attribute Summary collapse

Attributes inherited from Base

#namespace, #node, #source

Instance Method Summary collapse

Methods inherited from Base

#docstring, #filename, #kind, #location, #parameters, #signature, #value

Constructor Details

#initialize(source, node, namespace, access, docstring) ⇒ Attribute

Returns a new instance of Attribute.



6
7
8
9
10
# File 'lib/solargraph/pin/attribute.rb', line 6

def initialize source, node, namespace, access, docstring
  super(source, node, namespace)
  @access = access
  @docstring = docstring
end

Instance Attribute Details

#accessObject (readonly)

Returns the value of attribute access.



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

def access
  @access
end

Instance Method Details

#nameObject



12
13
14
# File 'lib/solargraph/pin/attribute.rb', line 12

def name
  @name ||= "#{node.children[0]}#{access == :writer ? '=' : ''}"
end

#pathObject



16
17
18
# File 'lib/solargraph/pin/attribute.rb', line 16

def path
  @path ||= namespace + '#' + name
end

#return_typeObject



20
21
22
23
24
25
26
# File 'lib/solargraph/pin/attribute.rb', line 20

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