class TypeProf::LSP::Reader

Public Class Methods

new(io) click to toggle source
# File typeprof-0.21.3/lib/typeprof/lsp.rb, line 782
def initialize(io)
  @io = io
end

Public Instance Methods

read() { |json| ... } click to toggle source
# File typeprof-0.21.3/lib/typeprof/lsp.rb, line 786
def read
  while line = @io.gets
    line2 = @io.gets
    if line =~ /\AContent-length: (\d+)\r\n\z/i && line2 == "\r\n"
      len = $1.to_i
      json = JSON.parse(@io.read(len), symbolize_names: true)
      yield json
    else
      raise ProtocolError, "LSP broken header"
    end
  end
end