Sha256: 4226f116fe15e3c636df44a798347d2a8b4fa02630cb47e8e35dfff8f912da81
Contents?: true
Size: 735 Bytes
Versions: 1
Compression:
Stored size: 735 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] raise 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
twitter-5.17.0 | lib/twitter/streaming/response.rb |