Parent

Class/Module Index [+]

Quicksearch

Twitter::Streaming::Response

Public Class Methods

new(&block) click to toggle source

Initializes a new Response object

@return [Twitter::Streaming::Response]

# File lib/twitter/streaming/response.rb, line 9
def initialize(&block)
  @block     = block
  @parser    = Http::Parser.new(self)
  @tokenizer = BufferedTokenizer.new("\r\n")
end

Public Instance Methods

<<(data) click to toggle source
# File lib/twitter/streaming/response.rb, line 15
def <<(data)
  @parser << data
end
on_body(data) click to toggle source
# File lib/twitter/streaming/response.rb, line 24
def on_body(data)
  @tokenizer.extract(data).each do |line|
    next if line.empty?
    @block.call(JSON.parse(line, :symbolize_names => true))
  end
end
on_headers_complete(_headers) click to toggle source
# File lib/twitter/streaming/response.rb, line 19
def on_headers_complete(_headers)
  error = Twitter::Error.errors[@parser.status_code]
  fail error.new if error
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.