Sha256: 13f9542d5b0401d8f8d80fed34f3f34f1b02349445f252ae72f3374e103c47a8
Contents?: true
Size: 940 Bytes
Versions: 5
Compression:
Stored size: 940 Bytes
Contents
module EventMachine module Twitter class Response attr_reader :body, :timestamp def initialize(body = '') @body = body end def concat(data) @timestamp = Time.now return unless data && data.size > 0 data.strip! return if data.empty? if json_start?(data) || json_end?(data) @body << data end end alias :<< :concat def complete? @body.size > 0 && json_start?(@body) && json_end?(@body) end def older_than?(seconds) @timestamp ||= Time.now age > seconds end def empty? @body == '' end def reset @body = '' end private def age Time.now - @timestamp end def json_start?(data) data[0,1] == '{' end def json_end?(data) data[data.length-1,1] == '}' end end end end
Version data entries
5 entries across 5 versions & 1 rubygems