Class: Viki::APIObject
Constant Summary
Constants included
from Utilities
Utilities::URL_NAMESPACES
Instance Attribute Summary collapse
Instance Method Summary
collapse
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
= hash["pagination"]
if
@next_url = ["next"] if not ["next"].empty?
@previous_url = ["previous"] if not ["previous"].empty?
end
@access_token = access_token
end
|
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
23
24
25
|
# File 'lib/viki/api_object.rb', line 23
def content
@content
end
|
#count ⇒ Object
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
|
#next? ⇒ Boolean
33
34
35
|
# File 'lib/viki/api_object.rb', line 33
def next?
!@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
|
#prev? ⇒ Boolean
37
38
39
|
# File 'lib/viki/api_object.rb', line 37
def prev?
!@previous_url.nil?
end
|