Class: Zuno::SseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/zuno.rb

Instance Method Summary collapse

Constructor Details

#initialize(&on_data) ⇒ SseParser

Returns a new instance of SseParser.



1969
1970
1971
1972
# File 'lib/zuno.rb', line 1969

def initialize(&on_data)
  @on_data = on_data
  @buffer = +""
end

Instance Method Details

#flushObject



1981
1982
1983
# File 'lib/zuno.rb', line 1981

def flush
  parse_buffer(final: true)
end

#push(chunk) ⇒ Object



1974
1975
1976
1977
1978
1979
# File 'lib/zuno.rb', line 1974

def push(chunk)
  return if chunk.nil? || chunk.empty?

  @buffer << chunk
  parse_buffer
end