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.
171 172 173 |
# File 'lib/typeprof/lsp/server.rb', line 171 def initialize(io) @io = io end |
Instance Method Details
#read ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 |
# File '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 |