class TypeProf::LSP::Reader - typeprof: Ruby Standard Library Documentation

# class TypeProf::LSP::Reader

### Public Class Methods

new(io) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/lsp/server.rb, line 171
    def initialize(io)
      @io = io
    end

### Public Instance Methods

read() { |json| ... } click to toggle source

    # File typeprof-0.30.1/lib/typeprof/lsp/server.rb, line 175
    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