Class: DribbbleBucketApi::BucketCollection
- Inherits:
-
Array
- Object
- Array
- DribbbleBucketApi::BucketCollection
- Defined in:
- lib/dribbble_bucket_api/bucket_collection.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
Returns the value of attribute current_page.
-
#total_entries ⇒ Object
Returns the value of attribute total_entries.
-
#total_pages ⇒ Object
Returns the value of attribute total_pages.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#current_page ⇒ Object
Returns the value of attribute current_page.
28 29 30 |
# File 'lib/dribbble_bucket_api/bucket_collection.rb', line 28 def current_page @current_page end |
#total_entries ⇒ Object
Returns the value of attribute total_entries.
28 29 30 |
# File 'lib/dribbble_bucket_api/bucket_collection.rb', line 28 def total_entries @total_entries end |
#total_pages ⇒ Object
Returns the value of attribute total_pages.
28 29 30 |
# File 'lib/dribbble_bucket_api/bucket_collection.rb', line 28 def total_pages @total_pages end |
Class Method Details
.retrieve(options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dribbble_bucket_api/bucket_collection.rb', line 5 def self.retrieve() # ensure we have a connection unless [:connection] raise ArgumentError, %Q( Options hash must contain :connection e.g: DribbbleBucketApi::BucketCollection.load(connection: connection) ) end # load the username username = [:connection].username # load the page response = PublicSite.new.user_buckets({ username: username, page: [:page] || 1 }) # create the new array new(response.buckets).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_page ⇒ Object
30 31 32 |
# File 'lib/dribbble_bucket_api/bucket_collection.rb', line 30 def next_page current_page + 1 end |
#prev_page ⇒ Object
34 35 36 |
# File 'lib/dribbble_bucket_api/bucket_collection.rb', line 34 def prev_page [current_page - 1, 1].max end |