Sha256: 8cafd51a429b1b9e3b2fb01bbe97943af022a323b4ff120bf67defffe7fb0002

Contents?: true

Size: 613 Bytes

Versions: 6

Compression:

Stored size: 613 Bytes

Contents

require_relative "public_site"
require_relative "shot"

module DribbbleBucketApi
	class ShotCollection < Array
		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

		attr_accessor :total_entries, :total_pages, :current_page

		def next_page
			current_page + 1
		end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dribbble-bucket-api-0.0.6 lib/dribbble_bucket_api/shot_collection.rb
dribbble-bucket-api-0.0.5 lib/dribbble_bucket_api/shot_collection.rb
dribbble-bucket-api-0.0.4 lib/dribbble_bucket_api/shot_collection.rb
dribbble-bucket-api-0.0.3 lib/dribbble_bucket_api/shot_collection.rb
dribbble-bucket-api-0.0.2 lib/dribbble_bucket_api/shot_collection.rb
dribbble-bucket-api-0.0.1 lib/dribbble_bucket_api/shot_collection.rb