Class: Pastvu::PhotoCollection
- Inherits:
-
Collection
- Object
- BasicResponse
- Collection
- Pastvu::PhotoCollection
- Defined in:
- lib/pastvu/photo/photo_collection.rb
Instance Attribute Summary
Attributes inherited from BasicResponse
Instance Method Summary collapse
-
#initialize(attributes, params = nil) ⇒ PhotoCollection
constructor
A new instance of PhotoCollection.
- #next(n_photos = nil) ⇒ Object
Methods inherited from Collection
Methods inherited from BasicResponse
Constructor Details
#initialize(attributes, params = nil) ⇒ PhotoCollection
Returns a new instance of PhotoCollection.
3 4 5 6 7 8 |
# File 'lib/pastvu/photo/photo_collection.rb', line 3 def initialize(attributes, params = nil) super attributes @params = params @path = %w[result photos] @model = Photo end |
Instance Method Details
#next(n_photos = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pastvu/photo/photo_collection.rb', line 10 def next(n_photos = nil) raise "next can be used with nearest photos requests only" if @params.nil? n_photos ||= @params[:limit] || 30 # params get passed to PhotoCollection when it is a request for nearest photos on.y raise ArgumentError, "n_photos must be Integer between 1 & 30" unless n_photos.instance_of?(Integer) && n_photos.between?(1, 30) new_skip = { skip: (@params[:skip] || 0) + n_photos } new_params = @params.merge(new_skip) Pastvu.nearest_photos(geo: @params[:geo], **new_params) end |