123456789_123456789_123456789_123456789_123456789_

Class: TypeProf::LSP::Writer

Relationships & Source Files
Inherits: Object
Defined in: lib/typeprof/lsp/server.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(io) ⇒ Writer

[ GitHub ]

  
# File 'lib/typeprof/lsp/server.rb', line 190

def initialize(io)
  @io = io
  @mutex = Mutex.new
end

Instance Method Details

#write(**json)

[ GitHub ]

  
# File 'lib/typeprof/lsp/server.rb', line 195

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