Class: InstagramBasicDisplay::Response
- Inherits:
-
Object
- Object
- InstagramBasicDisplay::Response
- Defined in:
- lib/instagram_basic_display/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#paging ⇒ Object
readonly
Returns the value of attribute paging.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #error ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #next_page? ⇒ Boolean
- #next_page_link ⇒ Object
- #payload ⇒ Object
- #previous_page? ⇒ Boolean
- #previous_page_link ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
21 22 23 24 25 26 |
# File 'lib/instagram_basic_display/response.rb', line 21 def initialize(response) @response = response @body = JSON.parse(response.body) @status = response.code @paging = body['paging'] end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
19 20 21 |
# File 'lib/instagram_basic_display/response.rb', line 19 def body @body end |
#paging ⇒ Object (readonly)
Returns the value of attribute paging.
19 20 21 |
# File 'lib/instagram_basic_display/response.rb', line 19 def paging @paging end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
19 20 21 |
# File 'lib/instagram_basic_display/response.rb', line 19 def response @response end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
19 20 21 |
# File 'lib/instagram_basic_display/response.rb', line 19 def status @status end |
Instance Method Details
#error ⇒ Object
52 53 54 55 56 57 |
# File 'lib/instagram_basic_display/response.rb', line 52 def error return unless body['error'] || body['error_message'] error_response = normalize_error(body) deserialize_json(error_response) end |
#next_page? ⇒ Boolean
28 29 30 |
# File 'lib/instagram_basic_display/response.rb', line 28 def next_page? !next_page_link.nil? end |
#next_page_link ⇒ Object
36 37 38 |
# File 'lib/instagram_basic_display/response.rb', line 36 def next_page_link paging['next'] if paging end |
#payload ⇒ Object
48 49 50 |
# File 'lib/instagram_basic_display/response.rb', line 48 def payload deserialize_json(body) end |
#previous_page? ⇒ Boolean
32 33 34 |
# File 'lib/instagram_basic_display/response.rb', line 32 def previous_page? !previous_page_link.nil? end |
#previous_page_link ⇒ Object
40 41 42 |
# File 'lib/instagram_basic_display/response.rb', line 40 def previous_page_link paging['previous'] if paging end |
#success? ⇒ Boolean
44 45 46 |
# File 'lib/instagram_basic_display/response.rb', line 44 def success? response. == 'OK' end |