123456789_123456789_123456789_123456789_123456789_

Class: TypeProf::LSP::Reader

Relationships & Source Files
Namespace Children
Exceptions:
Inherits: Object
Defined in: lib/typeprof/lsp.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(io) ⇒ Reader

[ GitHub ]

  
# File 'lib/typeprof/lsp.rb', line 782

def initialize(io)
  @io = io
end

Instance Method Details

#read

[ GitHub ]

  
# File '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