Class: Vertx::TimeoutStream

Inherits:
Object
  • Object
show all
Includes:
ReadStream
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb

Overview

A timeout stream is triggered by a timer, the Proc will be call when the timer is fired, it can be once or several times depending on the nature of the timer related to this stream. The will be called after the timer handler has been called.

Pausing the timer inhibits the timer shots until the stream is resumed. Setting a null handler callback cancels the timer.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)

26
27
28
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb', line 26

def @@j_api_type.accept?(obj)
  obj.class == TimeoutStream
end

+ (Object) j_api_type


35
36
37
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb', line 35

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


38
39
40
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb', line 38

def self.j_class
  Java::IoVertxCore::TimeoutStream.java_class
end

+ (Object) unwrap(obj)


32
33
34
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb', line 32

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)


29
30
31
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb', line 29

def @@j_api_type.wrap(obj)
  TimeoutStream.new(obj)
end

Instance Method Details

- (void) cancel

This method returns an undefined value.

Cancels the timeout. Note this has the same effect as calling #handler with a null argument.

Raises:

  • (ArgumentError)

123
124
125
126
127
128
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb', line 123

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

- (self) end_handler { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

113
114
115
116
117
118
119
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb', line 113

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 { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

70
71
72
73
74
75
76
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb', line 70

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)

Parameters:

  • amount (Fixnum) (defaults to: nil)

Returns:

  • (self)

Raises:

  • (ArgumentError)

104
105
106
107
108
109
110
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb', line 104

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 { ... }

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)

79
80
81
82
83
84
85
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb', line 79

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

- (self) pause

Returns:

  • (self)

Raises:

  • (ArgumentError)

87
88
89
90
91
92
93
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb', line 87

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

- (::Vertx::Pipe) pipe

Pause this stream and return a to transfer the elements of this stream to a destination .

The stream will be resumed when the pipe will be wired to a WriteStream.

Returns:

Raises:

  • (ArgumentError)

45
46
47
48
49
50
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb', line 45

def pipe
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:pipe, []).call(),::Vertx::Pipe, nil)
  end
  raise ArgumentError, "Invalid arguments when calling pipe()"
end

- (void) pipe_to(dst = nil) { ... }

This method returns an undefined value.

Pipe this ReadStream to the WriteStream.

Elements emitted by this stream will be written to the write stream until this stream ends or fails.

Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

Parameters:

Yields:

Raises:

  • (ArgumentError)

60
61
62
63
64
65
66
67
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb', line 60

def pipe_to(dst=nil)
  if dst.class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:pipeTo, [Java::IoVertxCoreStreams::WriteStream.java_class]).call(dst.j_del)
  elsif dst.class.method_defined?(:j_del) && block_given?
    return @j_del.java_method(:pipeTo, [Java::IoVertxCoreStreams::WriteStream.java_class,Java::IoVertxCore::Handler.java_class]).call(dst.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling pipe_to(#{dst})"
end

- (self) resume

Returns:

  • (self)

Raises:

  • (ArgumentError)

95
96
97
98
99
100
101
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/timeout_stream.rb', line 95

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