Class: LanguageServer::Protocol::Transport::Io::Reader
- Inherits:
-
Object
- Object
- LanguageServer::Protocol::Transport::Io::Reader
- Defined in:
- lib/language_server/protocol/transport/io/reader.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(io) ⇒ Reader
constructor
A new instance of Reader.
- #read(&block) ⇒ Object
Constructor Details
#initialize(io) ⇒ Reader
Returns a new instance of Reader.
10 11 12 13 |
# File 'lib/language_server/protocol/transport/io/reader.rb', line 10 def initialize(io) @io = io io.binmode end |
Instance Method Details
#read(&block) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/language_server/protocol/transport/io/reader.rb', line 15 def read(&block) while buffer = io.gets("\r\n\r\n") content_length = buffer.match(/Content-Length: (\d+)/i)[1].to_i = io.read(content_length) or raise request = JSON.parse(, symbolize_names: true) block.call(request) end end |