Class: EventMachine::Twitter::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/em-twitter/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body = '') ⇒ Response

Returns a new instance of Response.



7
8
9
# File 'lib/em-twitter/response.rb', line 7

def initialize(body = '')
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/em-twitter/response.rb', line 5

def body
  @body
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



5
6
7
# File 'lib/em-twitter/response.rb', line 5

def timestamp
  @timestamp
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/em-twitter/response.rb', line 26

def complete?
  @body.size > 0 && json_start?(@body) && json_end?(@body)
end

#concat(data) ⇒ Object Also known as: <<



11
12
13
14
15
16
17
18
19
20
21
22
23
# 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

#empty?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/em-twitter/response.rb', line 36

def empty?
  @body == ''
end

#older_than?(seconds) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
# File 'lib/em-twitter/response.rb', line 30

def older_than?(seconds)
  @timestamp ||= Time.now

  age > seconds
end

#resetObject



40
41
42
# File 'lib/em-twitter/response.rb', line 40

def reset
  @body = ''
end