Class: Reel::Stream
- Inherits:
-
Object
- Object
- Reel::Stream
- Defined in:
- lib/reel/stream.rb
Direct Known Subclasses
Instance Method Summary collapse
- #call(socket) ⇒ Object
- #close ⇒ Object (also: #finish)
- #closed? ⇒ Boolean
-
#each {|_self| ... } ⇒ Object
behaves like a true Rack::Response/BodyProxy object.
-
#initialize(&proc) ⇒ Stream
constructor
A new instance of Stream.
- #write(data) ⇒ Object (also: #<<)
Constructor Details
#initialize(&proc) ⇒ Stream
Returns a new instance of Stream.
3 4 5 |
# File 'lib/reel/stream.rb', line 3 def initialize(&proc) @proc = proc end |
Instance Method Details
#call(socket) ⇒ Object
7 8 9 10 |
# File 'lib/reel/stream.rb', line 7 def call(socket) @socket = socket @proc.call self end |
#close ⇒ Object Also known as: finish
25 26 27 |
# File 'lib/reel/stream.rb', line 25 def close @socket.close unless closed? end |
#closed? ⇒ Boolean
30 31 32 |
# File 'lib/reel/stream.rb', line 30 def closed? @socket.closed? end |
#each {|_self| ... } ⇒ Object
behaves like a true Rack::Response/BodyProxy object
21 22 23 |
# File 'lib/reel/stream.rb', line 21 def each yield self end |
#write(data) ⇒ Object Also known as: <<
12 13 14 15 16 17 |
# File 'lib/reel/stream.rb', line 12 def write(data) @socket << data data rescue IOError, Errno::ECONNRESET, Errno::EPIPE raise SocketError, "error writing to socket" end |