Class: RubyLsp::MessageReader
- Inherits:
-
Object
- Object
- RubyLsp::MessageReader
- Defined in:
- lib/ruby_lsp/utils.rb
Overview
Reads JSON RPC messages from the given IO in a loop
Instance Method Summary collapse
-
#each_message(&block) ⇒ Object
: () { (Hash[Symbol, untyped]) -> void } -> void.
-
#initialize(io) ⇒ MessageReader
constructor
: (IO) -> void.
Constructor Details
#initialize(io) ⇒ MessageReader
: (IO) -> void
312 313 314 |
# File 'lib/ruby_lsp/utils.rb', line 312 def initialize(io) @io = io end |
Instance Method Details
#each_message(&block) ⇒ Object
: () { (Hash[Symbol, untyped]) -> void } -> void
317 318 319 320 321 322 |
# File 'lib/ruby_lsp/utils.rb', line 317 def (&block) while (headers = @io.gets("\r\n\r\n")) = @io.read(headers[/Content-Length: (\d+)/i, 1].to_i) #: as !nil block.call(JSON.parse(, symbolize_names: true)) end end |