Class: Unsplash::CuratedBatch
- Defined in:
- lib/unsplash/curated_batch.rb
Overview
Unsplash Curated Batch operations.
Class Method Summary collapse
-
.all(page = 1, per_page = 10) ⇒ Array
Get a list of all curated batches.
-
.find(id) ⇒ Unsplash::CuratedBatch
Get a specific curated batch.
Instance Method Summary collapse
-
#photos ⇒ Array
Get a list of the photos contained in this batch.
Methods inherited from Client
#connection, connection, connection=, #initialize, #reload!, #to_h
Constructor Details
This class inherits a constructor from Unsplash::Client
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Unsplash::Client
Class Method Details
.all(page = 1, per_page = 10) ⇒ Array
Get a list of all curated batches.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/unsplash/curated_batch.rb', line 21 def all(page = 1, per_page = 10) params = { page: page, per_page: per_page } list = JSON.parse(connection.get("/curated_batches/", params).body) list.map do |cb| batch = Unsplash::CuratedBatch.new cb batch.curator = Unsplash::User.new batch.curator batch end end |
.find(id) ⇒ Unsplash::CuratedBatch
Get a specific curated batch.
11 12 13 14 15 |
# File 'lib/unsplash/curated_batch.rb', line 11 def find(id) batch = Unsplash::CuratedBatch.new JSON.parse(connection.get("/curated_batches/#{id}").body) batch.curator = Unsplash::User.new batch.curator batch end |
Instance Method Details
#photos ⇒ Array
Get a list of the photos contained in this batch.
37 38 39 40 |
# File 'lib/unsplash/curated_batch.rb', line 37 def photos list = JSON.parse(connection.get("/curated_batches/#{id}/photos").body) list.map { |photo| Unsplash::Photo.new photo } end |