Class: EventMachine::Twitter::Response
- Inherits:
-
Object
- Object
- EventMachine::Twitter::Response
- Defined in:
- lib/em-twitter/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #complete? ⇒ Boolean
- #concat(data) ⇒ Object (also: #<<)
- #empty? ⇒ Boolean
-
#initialize(body = '') ⇒ Response
constructor
A new instance of Response.
- #older_than?(seconds) ⇒ Boolean
- #reset ⇒ Object
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
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/em-twitter/response.rb', line 5 def body @body end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
5 6 7 |
# File 'lib/em-twitter/response.rb', line 5 def @timestamp end |
Instance Method Details
#complete? ⇒ 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
36 37 38 |
# File 'lib/em-twitter/response.rb', line 36 def empty? @body == '' end |
#older_than?(seconds) ⇒ Boolean
30 31 32 33 34 |
# File 'lib/em-twitter/response.rb', line 30 def older_than?(seconds) @timestamp ||= Time.now age > seconds end |
#reset ⇒ Object
40 41 42 |
# File 'lib/em-twitter/response.rb', line 40 def reset @body = '' end |