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.
264 265 266 |
# File 'lib/typeprof/lsp/server.rb', line 264 def initialize(io) @io = io end |
Instance Method Details
#read ⇒ Object
268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/typeprof/lsp/server.rb', line 268 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 |