Class: TypeProf::LSP::Writer
- Inherits:
-
Object
- Object
- TypeProf::LSP::Writer
- Defined in:
- lib/typeprof/lsp/server.rb
Instance Method Summary collapse
-
#initialize(io) ⇒ Writer
constructor
A new instance of Writer.
- #write(**json) ⇒ Object
Constructor Details
#initialize(io) ⇒ Writer
Returns a new instance of Writer.
283 284 285 286 |
# File 'lib/typeprof/lsp/server.rb', line 283 def initialize(io) @io = io @mutex = Mutex.new end |
Instance Method Details
#write(**json) ⇒ Object
288 289 290 291 292 293 294 |
# File 'lib/typeprof/lsp/server.rb', line 288 def write(**json) json = JSON.generate(json.merge(jsonrpc: "2.0")) @mutex.synchronize do @io << "Content-Length: #{ json.bytesize }\r\n\r\n" << json @io.flush end end |