Module: Vertx::ReadStream
- Included in:
- HttpClientResponse, WebSocket
- Defined in:
- lib/vertx/streams.rb
Overview
A mixin module which represents a stream of data that can be read from.
Any class that mixes in this module can be used by a Pump to pump data from a ReadStream to it.
Instance Method Summary collapse
- #_to_read_stream ⇒ Object
-
#data_handler(&hndlr) ⇒ Object
Set a data handler.
-
#end_handler(&hndlr) ⇒ Object
Set an end handler on the stream.
-
#exception_handler(&hndlr) ⇒ Object
Set an execption handler on the stream.
-
#pause ⇒ Object
Pause the ReadStream.
-
#resume ⇒ Object
Resume reading.
Instance Method Details
#_to_read_stream ⇒ Object
118 119 120 |
# File 'lib/vertx/streams.rb', line 118 def _to_read_stream @j_del end |
#data_handler(&hndlr) ⇒ Object
Set a data handler. As data is read, the handler will be called with the data.
84 85 86 87 88 89 |
# File 'lib/vertx/streams.rb', line 84 def data_handler(&hndlr) @j_del.dataHandler(Proc.new { |j_buff| hndlr.call(Buffer.new(j_buff)) }) self end |
#end_handler(&hndlr) ⇒ Object
Set an end handler on the stream. Once the stream has ended, and there is no more data to be read, this handler will be called.
112 113 114 115 |
# File 'lib/vertx/streams.rb', line 112 def end_handler(&hndlr) @j_del.endHandler(hndlr) self end |
#exception_handler(&hndlr) ⇒ Object
Set an execption handler on the stream.
105 106 107 108 |
# File 'lib/vertx/streams.rb', line 105 def exception_handler(&hndlr) @j_del.exceptionHandler(hndlr) self end |
#pause ⇒ Object
Pause the ReadStream. After calling this, the ReadStream will aim to send no more data to the #data_handler
92 93 94 95 |
# File 'lib/vertx/streams.rb', line 92 def pause @j_del.pause self end |
#resume ⇒ Object
Resume reading. If the ReadStream has been paused, reading will recommence on it.
98 99 100 101 |
# File 'lib/vertx/streams.rb', line 98 def resume @j_del.resume self end |