Class: Streamer::SSE
- Inherits:
-
Object
- Object
- Streamer::SSE
- Defined in:
- lib/gaku/streamer/sse.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(io) ⇒ SSE
constructor
A new instance of SSE.
- #write(object, options = {}) ⇒ Object
Constructor Details
#initialize(io) ⇒ SSE
Returns a new instance of SSE.
7 8 9 |
# File 'lib/gaku/streamer/sse.rb', line 7 def initialize(io) @io = io end |
Instance Method Details
#close ⇒ Object
18 19 20 |
# File 'lib/gaku/streamer/sse.rb', line 18 def close @io.close end |
#write(object, options = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/gaku/streamer/sse.rb', line 11 def write(object, = {}) .each do |k, v| @io.write "#{k}: #{v}\n" end @io.write "data: #{object}\n\n" end |