Class: Streamlog::SSE
- Inherits:
-
Object
- Object
- Streamlog::SSE
- Defined in:
- lib/streamlog/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.
5 6 7 |
# File 'lib/streamlog/sse.rb', line 5 def initialize(io) @io = io end |
Instance Method Details
#close ⇒ Object
16 17 18 |
# File 'lib/streamlog/sse.rb', line 16 def close @io.close end |
#write(object, options = {}) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/streamlog/sse.rb', line 9 def write(object, = {}) .each do |k, v| @io.write "#{k}: #{v}\n" end @io.write "data: #{JSON.dump(object)}\n\n" end |