Class: ComicVine::List
- Inherits:
-
Object
show all
- Includes:
- Enumerable
- Defined in:
- lib/comicvine/list.rb
Overview
Enumerable list for multiple ComicVine results
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(resp) ⇒ List
Returns a new instance of List.
15
16
17
18
19
20
|
# File 'lib/comicvine/list.rb', line 15
def initialize(resp)
@total_count = resp['number_of_total_results']
@page_count = resp['number_of_page_results']
@offset = resp['offset']
@limit = resp['limit']
end
|
Instance Attribute Details
#cvos ⇒ Object
13
14
15
|
# File 'lib/comicvine/list.rb', line 13
def cvos
@cvos
end
|
#limit ⇒ Object
12
13
14
|
# File 'lib/comicvine/list.rb', line 12
def limit
@limit
end
|
#offset ⇒ Object
11
12
13
|
# File 'lib/comicvine/list.rb', line 11
def offset
@offset
end
|
#page_count ⇒ Object
10
11
12
|
# File 'lib/comicvine/list.rb', line 10
def page_count
@page_count
end
|
#total_count ⇒ Object
9
10
11
|
# File 'lib/comicvine/list.rb', line 9
def total_count
@total_count
end
|
Instance Method Details
#each ⇒ Object
22
23
24
|
# File 'lib/comicvine/list.rb', line 22
def each
@cvos.each { |c| yield c }
end
|
#has_more? ⇒ true, false
Returns if there are more pages to load
46
47
48
|
# File 'lib/comicvine/list.rb', line 46
def has_more?
self.total_pages > self.page ? true : false
end
|
#last ⇒ Object
26
27
28
|
# File 'lib/comicvine/list.rb', line 26
def last
@cvos.last
end
|
#page ⇒ Integer
Returns the current page the object is on
32
33
34
|
# File 'lib/comicvine/list.rb', line 32
def page
(self.offset / self.limit) + 1
end
|
#total_pages ⇒ Integer
Returns the total number of pages available
39
40
41
|
# File 'lib/comicvine/list.rb', line 39
def total_pages
(self.total_count / self.limit) + 1
end
|