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, #last, #page

Constructor Details

#initialize(resp, resc) ⇒ ResourceList

Returns a new instance of ResourceList.

Since:

  • 0.1.0



52
53
54
55
56
57
# File 'lib/comicvine/list.rb', line 52

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



50
51
52
# File 'lib/comicvine/list.rb', line 50

def resource
  @resource
end

Instance Method Details

#next_pageObject

Since:

  • 0.1.0



59
60
61
62
# File 'lib/comicvine/list.rb', line 59

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

Since:

  • 0.1.0



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

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