class EventMachine::Twitter::Response

Attributes

body[R]
timestamp[R]

Public Class Methods

new(body = '') click to toggle source
# File lib/em-twitter/response.rb, line 7
def initialize(body = '')
  @body = body
end

Public Instance Methods

<<(data)
Alias for: concat
complete?() click to toggle source
# File lib/em-twitter/response.rb, line 26
def complete?
  @body.size > 0 && json_start?(@body) && json_end?(@body)
end
concat(data) click to toggle source
# File lib/em-twitter/response.rb, line 11
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
Also aliased as: <<
empty?() click to toggle source
# File lib/em-twitter/response.rb, line 36
def empty?
  @body == ''
end
older_than?(seconds) click to toggle source
# File lib/em-twitter/response.rb, line 30
def older_than?(seconds)
  @timestamp ||= Time.now

  age > seconds
end
reset() click to toggle source
# File lib/em-twitter/response.rb, line 40
def reset
  @body = ''
end

Private Instance Methods

age() click to toggle source
# File lib/em-twitter/response.rb, line 46
def age
  Time.now - @timestamp
end
json_end?(data) click to toggle source
# File lib/em-twitter/response.rb, line 54
def json_end?(data)
  data[data.length-1,1] == '}'
end
json_start?(data) click to toggle source
# File lib/em-twitter/response.rb, line 50
def json_start?(data)
  data[0,1] == '{'
end