Sha256: e2c2eab9a624966b888d82aaf42ef46e77bb017c9c91f0d2264f7be382eda786

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

module ItunesApi
  module Music
    module Results
      # Wrapper for album search results.
      class Album
        attr_reader_init :data, :store
        private :data

        def artist
          @artist ||= data['artistName']
        end

        def artwork
          @artwork ||= data['artworkUrl100']
        end

        def attributes
          [
            artist,
            artwork,
            collection_id,
            explicitness,
            genre,
            link,
            name,
            release_on,
            store,
            track_count
          ]
        end

        def collection_id
          @collection_id ||= data['collectionId']
        end

        def explicitness
          @explicitness ||= data['collectionExplicitness']
        end

        def genre
          @genre ||= data['primaryGenreName']
        end

        def link
          @link ||= data['collectionViewUrl']
        end

        def name
          @name ||= data['collectionName']
        end

        def release_on
          @release_on ||= Date.parse(data['releaseDate'])
        end

        def track_count
          @track_count ||= data['trackCount']
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
itunes_api-2.3.1 lib/itunes_api/music/results/album.rb
itunes_api-2.3.0 lib/itunes_api/music/results/album.rb
itunes_api-2.2.1 lib/itunes_api/music/results/album.rb
itunes_api-2.2.0 lib/itunes_api/music/results/album.rb
itunes_api-2.1.0 lib/itunes_api/music/results/album.rb