Sha256: ccc60e4d55e93dfcb4f455c2258eea34bd36e94ad23d844ac2ffce6a0741d302
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
require 'date' module ItunesApi module Music # Wrapper for album results. class Album attr_reader_init :data, :store private :data def self.build(albums_data, store) albums_data.map { |data| new(data, store) } .sort_by(&:released) .reverse end def artwork @artwork ||= data[:artworkUrl100] end def availability return :streaming if apple_music? :sale end def collection_id @collection_id ||= data[:collectionId] end def name @name ||= data[:collectionName] end def released @released ||= Date.parse(data[:releaseDate]) end def to_hash { artwork: artwork, collection_id: collection_id, name: name, released: released, availability: availability, store: store } end private def apple_music? tracklist.any?(&:streamable?) end def tracklist @tracklist ||= AlbumLookup.tracklist(collection_id, store) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
itunes_api-1.2.1 | lib/itunes_api/music/album.rb |