Class: Viki::APIObject
- Inherits:
-
Object
- Object
- Viki::APIObject
- Includes:
- Utilities
- Defined in:
- lib/viki/api_object.rb
Constant Summary
Constants included from Utilities
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
Instance Method Summary collapse
-
#initialize(json, access_token) ⇒ APIObject
constructor
A new instance of APIObject.
- #next ⇒ Object
- #prev ⇒ Object
Constructor Details
#initialize(json, access_token) ⇒ APIObject
Returns a new instance of APIObject.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/viki/api_object.rb', line 8 def initialize(json, access_token) hash = MultiJson.load(json) @content = hash["response"] ? hash["response"] : hash @count = hash["count"] ? hash["count"].to_i : 1 pagination = hash["pagination"] if pagination @next_url = pagination["next"] if not pagination["next"].empty? @previous_url = pagination["previous"] if not pagination["previous"].empty? end @access_token = access_token end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
23 24 25 |
# File 'lib/viki/api_object.rb', line 23 def content @content end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
23 24 25 |
# File 'lib/viki/api_object.rb', line 23 def count @count end |
Instance Method Details
#next ⇒ Object
25 26 27 |
# File 'lib/viki/api_object.rb', line 25 def next @next_url ? direct_request(@next_url) : nil end |
#prev ⇒ Object
29 30 31 |
# File 'lib/viki/api_object.rb', line 29 def prev @previous_url ? direct_request(@previous_url) : nil end |