Class: DribbbleBucketApi::ShotCollection

Inherits:
Array
  • Object
show all
Defined in:
lib/dribbble_bucket_api/shot_collection.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_pageObject

Returns the value of attribute current_page.



19
20
21
# File 'lib/dribbble_bucket_api/shot_collection.rb', line 19

def current_page
  @current_page
end

#total_entriesObject

Returns the value of attribute total_entries.



19
20
21
# File 'lib/dribbble_bucket_api/shot_collection.rb', line 19

def total_entries
  @total_entries
end

#total_pagesObject

Returns the value of attribute total_pages.



19
20
21
# File 'lib/dribbble_bucket_api/shot_collection.rb', line 19

def total_pages
  @total_pages
end

Class Method Details

.retrieve(options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dribbble_bucket_api/shot_collection.rb', line 6

def self.retrieve(options)
	# load the page
	response = PublicSite.new.bucket_contents({
		page: 1
	}.merge(options))
	# create the new array
	new(response.shots).tap do |arr|
		arr.total_entries = response.total_entries
		arr.total_pages = response.total_pages
		arr.current_page = response.current_page
	end
end

Instance Method Details

#next_pageObject



21
22
23
# File 'lib/dribbble_bucket_api/shot_collection.rb', line 21

def next_page
	current_page + 1
end

#prev_pageObject



25
26
27
# File 'lib/dribbble_bucket_api/shot_collection.rb', line 25

def prev_page
	[current_page - 1, 1].max
end