Class: Pexels::CollectionMediaSet
- Inherits:
-
PaginatedResponse
- Object
- PaginatedResponse
- Pexels::CollectionMediaSet
- Defined in:
- lib/pexels/collection_media_set.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Attributes inherited from PaginatedResponse
#page, #per_page, #total_results
Instance Method Summary collapse
-
#initialize(response) ⇒ CollectionMediaSet
constructor
A new instance of CollectionMediaSet.
- #photos ⇒ Object
- #videos ⇒ Object
Methods inherited from PaginatedResponse
#each, #next_page, #prev_page, #total_pages
Constructor Details
#initialize(response) ⇒ CollectionMediaSet
Returns a new instance of CollectionMediaSet.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pexels/collection_media_set.rb', line 8 def initialize(response) super @id = attrs.fetch('id') @data = attrs.fetch('media', []).map do |attrs| if attrs['type'] == 'Photo' Pexels::Photo.new(attrs) elsif attrs['type'] == 'Video' Pexels::Video.new(attrs) end end rescue KeyError => exception raise Pexels::MalformedAPIResponseError.new(exception) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/pexels/collection_media_set.rb', line 6 def id @id end |