Class: Solargraph::Suggestion

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/suggestion.rb

Constant Summary collapse

CLASS =
'Class'
KEYWORD =
'Keyword'
MODULE =
'Module'
METHOD =
'Method'
VARIABLE =
'Variable'
SNIPPET =
'Snippet'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label, kind: KEYWORD, insert: nil, detail: nil, documentation: nil, code_object: nil) ⇒ Suggestion

Returns a new instance of Suggestion.



15
16
17
18
19
20
21
22
# File 'lib/solargraph/suggestion.rb', line 15

def initialize label, kind: KEYWORD, insert: nil, detail: nil, documentation: nil, code_object: nil
  @label = label.to_s
  @kind = kind
  @insert = insert || @label
  @detail = detail
  @code_object = code_object
  @documentation = documentation
end

Instance Attribute Details

#detail ⇒ Object (readonly)

Returns the value of attribute detail.



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

def detail
  @detail
end

#documentation ⇒ Object (readonly)

Returns the value of attribute documentation.



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

def documentation
  @documentation
end

#insert ⇒ Object (readonly)

Returns the value of attribute insert.



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

def insert
  @insert
end

#kind ⇒ Object (readonly)

Returns the value of attribute kind.



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

def kind
  @kind
end

#label ⇒ Object (readonly)

Returns the value of attribute label.



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

def label
  @label
end

Instance Method Details

#to_json(args = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/solargraph/suggestion.rb', line 28

def to_json args={}
  {
    label: @label,
    kind: @kind,
    insert: @insert,
    detail: @detail,
    #documentation: (@documentation.nil? ? nil : @documentation.all)
    documentation: (@code_object.nil? ? nil : YARD::Templates::Engine.render(format: :text, object: @code_object))
  }.to_json(args)
end

#to_s ⇒ Object



24
25
26
# File 'lib/solargraph/suggestion.rb', line 24

def to_s
  label
end