Class: Spoom::LSP::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/spoom/sorbet/lsp/base.rb

Overview

A general message as defined by JSON-RPC.

The language server protocol always uses `“2.0”` as the `jsonrpc` version.

Direct Known Subclasses

Notification, Request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMessage

Returns a new instance of Message.


15
16
17
# File 'lib/spoom/sorbet/lsp/base.rb', line 15

def initialize
  @jsonrpc = '2.0'
end

Instance Attribute Details

#jsonrpcObject (readonly)

Returns the value of attribute jsonrpc.


13
14
15
# File 'lib/spoom/sorbet/lsp/base.rb', line 13

def jsonrpc
  @jsonrpc
end

Instance Method Details

#as_jsonObject


19
20
21
22
23
24
# File 'lib/spoom/sorbet/lsp/base.rb', line 19

def as_json
  instance_variables.each_with_object({}) do |var, obj|
    val = instance_variable_get(var)
    obj[var.to_s.delete('@')] = val if val
  end
end

#to_json(*args) ⇒ Object


26
27
28
# File 'lib/spoom/sorbet/lsp/base.rb', line 26

def to_json(*args)
  as_json.to_json(*args)
end