Class: Stream
- Inherits:
-
Object
- Object
- Stream
- Defined in:
- lib/pubsubstub/stream.rb
Instance Method Summary collapse
- #<<(data) ⇒ Object
- #close ⇒ Object
- #closed? ⇒ Boolean
- #each(&front) ⇒ Object
-
#initialize(&callback) ⇒ Stream
constructor
A new instance of Stream.
Constructor Details
#initialize(&callback) ⇒ Stream
Returns a new instance of Stream.
2 3 4 5 |
# File 'lib/pubsubstub/stream.rb', line 2 def initialize(&callback) @callback = callback @closed = false end |
Instance Method Details
#<<(data) ⇒ Object
17 18 19 20 |
# File 'lib/pubsubstub/stream.rb', line 17 def <<(data) @front.call(data.to_s) self end |
#close ⇒ Object
7 8 9 |
# File 'lib/pubsubstub/stream.rb', line 7 def close @closed = true end |
#closed? ⇒ Boolean
22 23 24 |
# File 'lib/pubsubstub/stream.rb', line 22 def closed? @closed end |
#each(&front) ⇒ Object
11 12 13 14 15 |
# File 'lib/pubsubstub/stream.rb', line 11 def each(&front) @front = front @callback.call(self) close end |