Sha256: 80cd76c6ce5bb1bd5d573282037612da12ec3a2eac017a45c90a352fd6438e54

Contents?: true

Size: 603 Bytes

Versions: 1

Compression:

Stored size: 603 Bytes

Contents

module ItunesApi
  module Music
    # Artists or Bands resulting from a search
    class ArtistSearch
      attr_reader_init :name, :store
      selfie :artists

      def artists
        @artists ||= artist_ids.map { |id| build_artist(id) }.compact
      end

      private

      def artist_ids
        @search ||= ItunesApi.artist_ids(name, store)
      end

      def build_artist(id)
        if (lookup = lookup(id))
          Artist.new(lookup)
        end
      end

      def lookup(id)
        Requests::Lookup.artist_with_albums(id, store)
      rescue
        nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itunes_api-1.0.0 lib/itunes_api/music/artist_search.rb