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.

Author:

Instance Method Summary collapse

Instance Method Details

#_to_read_streamObject



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.

Parameters:

  • hndlr. (Block)

    The data handler



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.

Parameters:

  • hndlr. (Block)

    The exception handler



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.

Parameters:

  • hndlr. (Block)

    The exception handler



105
106
107
108
# File 'lib/vertx/streams.rb', line 105

def exception_handler(&hndlr)
  @j_del.exceptionHandler(hndlr)
  self
end

#pauseObject

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

#resumeObject

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