Class: Spoom::LSP::Message
- Inherits:
-
Object
- Object
- Spoom::LSP::Message
- 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 Method Summary collapse
-
#as_json ⇒ Object
: -> Hash[untyped, untyped].
-
#initialize ⇒ Message
constructor
: -> void.
-
#to_json(*args) ⇒ Object
: (*untyped args) -> String.
Constructor Details
#initialize ⇒ Message
: -> void
14 15 16 |
# File 'lib/spoom/sorbet/lsp/base.rb', line 14 def initialize @jsonrpc = "2.0" #: String end |
Instance Method Details
#as_json ⇒ Object
: -> Hash[untyped, untyped]
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
: (*untyped args) -> String
27 28 29 |
# File 'lib/spoom/sorbet/lsp/base.rb', line 27 def to_json(*args) T.unsafe(as_json).to_json(*args) end |