Class: ItunesApi::Music::Album
- Inherits:
-
Object
- Object
- ItunesApi::Music::Album
- Defined in:
- lib/itunes_api/music/album.rb
Overview
Wrapper for album results.
Class Method Summary collapse
Instance Method Summary collapse
- #artwork ⇒ Object
- #availability ⇒ Object
- #collection_id ⇒ Object
- #name ⇒ Object
- #released ⇒ Object
- #to_hash ⇒ Object
Class Method Details
.build(albums_data, store) ⇒ Object
9 10 11 12 13 |
# File 'lib/itunes_api/music/album.rb', line 9 def self.build(albums_data, store) albums_data.map { |data| new(data, store) } .sort_by(&:released) .reverse end |
Instance Method Details
#artwork ⇒ Object
15 16 17 |
# File 'lib/itunes_api/music/album.rb', line 15 def artwork @artwork ||= data[:artworkUrl100] end |
#availability ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/itunes_api/music/album.rb', line 19 def availability prefix = pre_release? ? 'pre_release_' : '' if apple_music? "#{prefix}streaming".to_sym else "#{prefix}sale".to_sym end end |
#collection_id ⇒ Object
29 30 31 |
# File 'lib/itunes_api/music/album.rb', line 29 def collection_id @collection_id ||= data[:collectionId] end |
#name ⇒ Object
33 34 35 |
# File 'lib/itunes_api/music/album.rb', line 33 def name @name ||= data[:collectionName] end |
#released ⇒ Object
37 38 39 |
# File 'lib/itunes_api/music/album.rb', line 37 def released @released ||= Date.parse(data[:releaseDate]) end |
#to_hash ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/itunes_api/music/album.rb', line 41 def to_hash { artwork: artwork, collection_id: collection_id, name: name, released: released, availability: availability, store: store } end |