Sha256: 990c0f64e3bd0adf5bf819c76921a28cf25cd9df27895b40984b368d14f166a5
Contents?: true
Size: 734 Bytes
Versions: 8
Compression:
Stored size: 734 Bytes
Contents
require 'buftok' module Twitter module Streaming class Response # Initializes a new Response object # # @return [Twitter::Streaming::Response] def initialize(&block) @block = block @parser = Http::Parser.new(self) @tokenizer = BufferedTokenizer.new("\r\n") end def <<(data) @parser << data end def on_headers_complete(_headers) error = Twitter::Error.errors[@parser.status_code] fail error.new if error end def on_body(data) @tokenizer.extract(data).each do |line| next if line.empty? @block.call(JSON.parse(line, :symbolize_names => true)) end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems