Class: Spoom::LSP::Message
- Inherits:
-
Object
- Object
- Spoom::LSP::Message
- Extended by:
- T::Sig
- 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
Instance Attribute Summary collapse
-
#jsonrpc ⇒ Object
readonly
Returns the value of attribute jsonrpc.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize ⇒ Message
constructor
A new instance of Message.
- #to_json(*args) ⇒ Object
Constructor Details
#initialize ⇒ Message
Returns a new instance of Message.
19 20 21 |
# File 'lib/spoom/sorbet/lsp/base.rb', line 19 def initialize @jsonrpc = T.let("2.0", String) end |
Instance Attribute Details
#jsonrpc ⇒ Object (readonly)
Returns the value of attribute jsonrpc.
16 17 18 |
# File 'lib/spoom/sorbet/lsp/base.rb', line 16 def jsonrpc @jsonrpc end |
Instance Method Details
#as_json ⇒ Object
24 25 26 27 28 29 |
# File 'lib/spoom/sorbet/lsp/base.rb', line 24 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
32 33 34 |
# File 'lib/spoom/sorbet/lsp/base.rb', line 32 def to_json(*args) T.unsafe(as_json).to_json(*args) end |