Class: Solargraph::Pin::Namespace

Inherits:
Base
  • Object
show all
Includes:
NodeMethods
Defined in:
lib/solargraph/pin/namespace.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#namespace, #node, #source

Instance Method Summary collapse

Methods included from NodeMethods

#const_from, #infer_literal_node_type, #pack_name, #resolve_node_signature, #unpack_name

Methods inherited from Base

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

Constructor Details

#initialize(source, node, namespace, visibility) ⇒ Namespace

Returns a new instance of Namespace.



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

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

Instance Attribute Details

#visibility ⇒ Object (readonly)

Returns the value of attribute visibility.



6
7
8
# File 'lib/solargraph/pin/namespace.rb', line 6

def visibility
  @visibility
end

Instance Method Details

#kind ⇒ Object



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

def kind
  @kind ||= (node.type == :class ? Solargraph::Suggestion::CLASS : Solargraph::Suggestion::MODULE)
end

#name ⇒ Object



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

def name
  @name ||= pack_name(node.children[0]).last.to_s
end

#path ⇒ Object



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

def path
  @path ||= (namespace.empty? ? '' : "#{namespace}::") + name
end

#return_type ⇒ Object



25
26
27
# File 'lib/solargraph/pin/namespace.rb', line 25

def return_type
  @return_type ||= (node.type == :class ? 'Class' : 'Module') + "<#{path}>"
end