Class: RubyLsp::ResponseBuilders::Hover
- Inherits:
-
ResponseBuilder
- Object
- ResponseBuilder
- RubyLsp::ResponseBuilders::Hover
- Defined in:
- lib/ruby_lsp/response_builders/hover.rb
Overview
: [ResponseType = String]
Instance Method Summary collapse
-
#empty? ⇒ Boolean
: -> bool.
-
#initialize ⇒ Hover
constructor
: -> void.
-
#push(content, category:) ⇒ Object
: (String content, category: Symbol) -> void.
-
#response ⇒ Object
: -> ResponseType.
Constructor Details
#initialize ⇒ Hover
: -> void
9 10 11 12 13 14 15 16 17 |
# File 'lib/ruby_lsp/response_builders/hover.rb', line 9 def initialize super @response = { title: +"", links: +"", documentation: +"", } #: Hash[Symbol, String] end |
Instance Method Details
#empty? ⇒ Boolean
: -> bool
28 29 30 |
# File 'lib/ruby_lsp/response_builders/hover.rb', line 28 def empty? @response.values.all?(&:empty?) end |
#push(content, category:) ⇒ Object
: (String content, category: Symbol) -> void
20 21 22 23 24 25 |
# File 'lib/ruby_lsp/response_builders/hover.rb', line 20 def push(content, category:) hover_content = @response[category] if hover_content hover_content << content + "\n" end end |
#response ⇒ Object
: -> ResponseType
34 35 36 37 38 39 40 |
# File 'lib/ruby_lsp/response_builders/hover.rb', line 34 def response result = @response[:title] #: as !nil result << "\n" << @response[:links] if @response[:links] result << "\n" << @response[:documentation] if @response[:documentation] result.strip end |