Sha256: c5a372f6801321f9353e78132bb910fdb056d2c6aa9bd3c7b364ceff1ddeab37

Contents?: true

Size: 855 Bytes

Versions: 3

Compression:

Stored size: 855 Bytes

Contents

# frozen_string_literal: true

module ItunesApi
  module Music
    module Results
      # Wrapper for artist search results.
      class Artist
        attr_reader_init :data, :store, search_term: nil
        private :data, :search_term

        def amg_id
          @amg_id ||= data['amgArtistId']
        end

        def apple_id
          @apple_id ||= data['artistId']
        end

        def attributes
          [amg_id, apple_id, genre, link, name, store]
        end

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

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

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

        def relevant?
          return true unless search_term

          name.downcase.include?(search_term.downcase)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
itunes_api-2.4.1 lib/itunes_api/music/results/artist.rb
itunes_api-2.4.0 lib/itunes_api/music/results/artist.rb
itunes_api-2.3.2 lib/itunes_api/music/results/artist.rb