Class: ScalarRubyTest::Runtime::Stream
- Inherits:
-
Object
- Object
- ScalarRubyTest::Runtime::Stream
- Includes:
- Enumerable
- Defined in:
- lib/amritk-scalar-test/runtime.rb
Instance Attribute Summary collapse
-
#last_event_id ⇒ Object
readonly
Returns the value of attribute last_event_id.
-
#last_event_name ⇒ Object
readonly
Returns the value of attribute last_event_name.
-
#retry_after ⇒ Object
readonly
Returns the value of attribute retry_after.
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
- #each(&block) ⇒ Object
-
#initialize(source:, descriptor:, format: :sse, handlers: []) ⇒ Stream
constructor
A new instance of Stream.
Constructor Details
#initialize(source:, descriptor:, format: :sse, handlers: []) ⇒ Stream
Returns a new instance of Stream.
267 268 269 270 271 272 273 274 275 276 |
# File 'lib/amritk-scalar-test/runtime.rb', line 267 def initialize(source:, descriptor:, format: :sse, handlers: []) @source = source @descriptor = descriptor @format = format @handlers = handlers @closed = false @retry_after = nil @last_event_id = nil @last_event_name = nil end |
Instance Attribute Details
#last_event_id ⇒ Object (readonly)
Returns the value of attribute last_event_id.
298 299 300 |
# File 'lib/amritk-scalar-test/runtime.rb', line 298 def last_event_id @last_event_id end |
#last_event_name ⇒ Object (readonly)
Returns the value of attribute last_event_name.
298 299 300 |
# File 'lib/amritk-scalar-test/runtime.rb', line 298 def last_event_name @last_event_name end |
#retry_after ⇒ Object (readonly)
Returns the value of attribute retry_after.
298 299 300 |
# File 'lib/amritk-scalar-test/runtime.rb', line 298 def retry_after @retry_after end |
Instance Method Details
#close ⇒ Object
290 291 292 |
# File 'lib/amritk-scalar-test/runtime.rb', line 290 def close @closed = true end |
#closed? ⇒ Boolean
294 295 296 |
# File 'lib/amritk-scalar-test/runtime.rb', line 294 def closed? @closed end |
#each(&block) ⇒ Object
278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/amritk-scalar-test/runtime.rb', line 278 def each(&block) return enum_for(:each) unless block return if @closed each_event do |data| break if @closed next if stream_action(data) == :skip block.call(Runtime.deserialize(Runtime.parse_json(data), @descriptor)) end ensure close end |