Class: ComicVine::ResourceList

Inherits:
List
  • Object
show all
Defined in:
lib/comicvine/list.rb

Overview

Class container for multiple ComicVine resources

Since:

  • 0.1.0

Instance Attribute Summary collapse

Attributes inherited from List

#cvos, #limit, #offset, #page_count, #total_count

Instance Method Summary collapse

Methods inherited from List

#each, #has_more?, #last, #page, #total_pages

Constructor Details

#initialize(resp, resc) ⇒ ResourceList

Returns a new instance of ResourceList.

Since:

  • 0.1.0



67
68
69
70
71
72
# File 'lib/comicvine/list.rb', line 67

def initialize(resp, resc)
  super(resp)

  @resource = resc
  @cvos = resp['results'].map { |r| ComicVine::Resource.create_resource(r) }
end

Instance Attribute Details

#resourceObject (readonly)

Since:

  • 0.1.0



65
66
67
# File 'lib/comicvine/list.rb', line 65

def resource
  @resource
end

Instance Method Details

#next_pageObject Also known as: next_page!

Loads the next page results

Since:

  • 0.1.0



75
76
77
78
# File 'lib/comicvine/list.rb', line 75

def next_page
  return nil if (@offset + @page_count) >= @total_count
  update_ivals(ComicVine::API.send(@resource, {:limit => @limit, :offset => (@offset + @page_count)}))
end

#prev_pageObject Also known as: prev_page!

Loads the previous page results

Since:

  • 0.1.0



81
82
83
84
# File 'lib/comicvine/list.rb', line 81

def prev_page
  return nil if @offset == 0
  update_ivals(ComicVine::API.send(@resource, {:limit => @limit, :offset => (@offset - @page_count)}))
end