Class: TypeProf::LSP::Reader
- Inherits:
-
Object
- Object
- TypeProf::LSP::Reader
- Defined in:
- lib/typeprof/lsp/server.rb
Defined Under Namespace
Classes: ProtocolError
Instance Method Summary collapse
-
#initialize(io) ⇒ Reader
constructor
A new instance of Reader.
- #read ⇒ Object
Constructor Details
#initialize(io) ⇒ Reader
Returns a new instance of Reader.
295 296 297 |
# File 'lib/typeprof/lsp/server.rb', line 295 def initialize(io) @io = io end |
Instance Method Details
#read ⇒ Object
299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/typeprof/lsp/server.rb', line 299 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 |