Class: Streamer::SSE

Inherits:
Object
  • Object
show all
Defined in:
lib/gaku/streamer/sse.rb

Instance Method Summary collapse

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

#closeObject



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, options = {})
  options.each do |k, v|
    @io.write "#{k}: #{v}\n"
  end
  @io.write "data: #{object}\n\n"
end