Class: ItunesApi::Requests::Search

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/itunes_api/requests/search.rb

Overview

Fetch all the artist ids corresponding to a search term

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

#results

Constructor Details

#initialize(artist_name) ⇒ Search

Returns a new instance of Search.



7
8
9
# File 'lib/itunes_api/requests/search.rb', line 7

def initialize(artist_name)
  @artist_name = artist_name
end

Class Method Details

.artist_ids(artist_name) ⇒ Object



11
12
13
# File 'lib/itunes_api/requests/search.rb', line 11

def self.artist_ids(artist_name)
  new(artist_name).artist_ids
end

Instance Method Details

#artist_ids ⇒ Object



15
16
17
18
19
# File 'lib/itunes_api/requests/search.rb', line 15

def artist_ids
  results.collect do |result|
    result['amgArtistId']
  end.compact.uniq.sort
end