Module: Vertx::ReadStream

Includes:
StreamBase
Included in:
AsyncFile, DatagramSocket, HttpClientRequest, HttpClientResponse, HttpServerFileUpload, HttpServerRequest, JsonParser, MessageConsumer, NetSocket, ReadStreamImpl, RecordParser, TimeoutStream, WebSocketBase, VertxCassandra::CassandraRowStream, VertxKafkaClient::KafkaConsumer, VertxRabbitmq::RabbitMQConsumer, VertxSql::SQLRowStream, VertxUnit::TestSuiteReport, VertxWeb::SockJSSocket
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/read_stream.rb

Instance Method Summary (collapse)

Instance Method Details

- (self) end_handler { ... }

Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

64
65
66
67
68
69
70
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/read_stream.rb', line 64

def end_handler
  if block_given?
    @j_del.java_method(:endHandler, [Java::IoVertxCore::Handler.java_class]).call(Proc.new { yield })
    return self
  end
  raise ArgumentError, "Invalid arguments when calling end_handler()"
end

- (self) exception_handler { ... }

Set an exception handler on the read stream.

Yields:

  • the exception handler

Returns:

  • (self)

Raises:

  • (ArgumentError)

10
11
12
13
14
15
16
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/read_stream.rb', line 10

def exception_handler
  if block_given?
    @j_del.java_method(:exceptionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.from_throwable(event)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling exception_handler()"
end

- (self) fetch(amount = nil)

Fetch the specified amount of elements. If the ReadStream has been paused, reading will recommence with the specified amount of items, otherwise the specified amount will be added to the current stream demand.

Parameters:

  • amount (Fixnum) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)

54
55
56
57
58
59
60
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/read_stream.rb', line 54

def fetch(amount=nil)
  if amount.class == Fixnum && !block_given?
    @j_del.java_method(:fetch, [Java::long.java_class]).call(amount)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling fetch(#{amount})"
end

- (self) handler { ... }

Set a data handler. As data is read, the handler will be called with the data.

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

20
21
22
23
24
25
26
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/read_stream.rb', line 20

def handler
  if block_given?
    @j_del.java_method(:handler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(@j_arg_T.wrap(event)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling handler()"
end

- (self) pause

Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

While it's paused, no data will be sent to the data handler.

Returns:

  • (self)

Raises:

  • (ArgumentError)

31
32
33
34
35
36
37
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/read_stream.rb', line 31

def pause
  if !block_given?
    @j_del.java_method(:pause, []).call()
    return self
  end
  raise ArgumentError, "Invalid arguments when calling pause()"
end

- (self) resume

Resume reading, and sets the buffer in flowing mode.

If the ReadStream has been paused, reading will recommence on it.

Returns:

  • (self)

Raises:

  • (ArgumentError)

42
43
44
45
46
47
48
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/read_stream.rb', line 42

def resume
  if !block_given?
    @j_del.java_method(:resume, []).call()
    return self
  end
  raise ArgumentError, "Invalid arguments when calling resume()"
end