Class: ComicVine::CVSearchList
- Defined in:
- lib/comic_vine/cv_list.rb
Overview
A paginated list of search results (from API.search).
Instance Attribute Summary collapse
-
#query ⇒ String
readonly
The search query.
-
#resource ⇒ String
readonly
The resource type(s) searched.
Attributes inherited from CVList
#cvos, #limit, #offset, #page_count, #total_count
Instance Method Summary collapse
-
#initialize(resp, resc, query, opts = {}) ⇒ CVSearchList
constructor
A new instance of CVSearchList.
-
#next_page ⇒ CVSearchList?
Advances to the next page of results, updating the list in place.
-
#prev_page ⇒ CVSearchList?
Steps back to the previous page of results, updating the list in place.
Methods inherited from CVList
Constructor Details
#initialize(resp, resc, query, opts = {}) ⇒ CVSearchList
Returns a new instance of CVSearchList.
108 109 110 111 112 113 114 115 |
# File 'lib/comic_vine/cv_list.rb', line 108 def initialize(resp, resc, query, opts = {}) super(resp) @resource = resc @query = query @opts = opts || {} @cvos = resp['results'].map { |r| ComicVine::CVObject.new(r) } end |
Instance Attribute Details
#query ⇒ String (readonly)
Returns the search query.
102 103 104 |
# File 'lib/comic_vine/cv_list.rb', line 102 def query @query end |
#resource ⇒ String (readonly)
Returns the resource type(s) searched.
100 101 102 |
# File 'lib/comic_vine/cv_list.rb', line 100 def resource @resource end |
Instance Method Details
#next_page ⇒ CVSearchList?
Advances to the next page of results, updating the list in place.
121 122 123 124 125 126 |
# File 'lib/comic_vine/cv_list.rb', line 121 def next_page return nil if (@offset + @page_count) >= @total_count update_ivals(ComicVine::API.search(@resource, @query, @opts.merge(:limit => @limit, :page => page + 1))) self end |
#prev_page ⇒ CVSearchList?
Steps back to the previous page of results, updating the list in place.
132 133 134 135 136 137 |
# File 'lib/comic_vine/cv_list.rb', line 132 def prev_page return nil if @offset == 0 update_ivals(ComicVine::API.search(@resource, @query, @opts.merge(:limit => @limit, :page => page - 1))) self end |