Class: ItunesApi::Music::Artist

Inherits:
Object
  • Object
show all
Defined in:
lib/itunes_api/music/artist.rb

Overview

Artist or Band from the Apple catalog

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_by_apple_id(apple_id, store) ⇒ Object



16
17
18
19
20
# File 'lib/itunes_api/music/artist.rb', line 16

def find_by_apple_id(apple_id, store)
  result = artists(apple_id, store).first

  new(*result.attributes) if result
end

.find_by_name(name, store) ⇒ Object



10
11
12
13
14
# File 'lib/itunes_api/music/artist.rb', line 10

def find_by_name(name, store)
  Requests::Search.artists(name, store).map do |result|
    new(*result.attributes)
  end
end

Instance Method Details

#albumsObject



29
30
31
# File 'lib/itunes_api/music/artist.rb', line 29

def albums
  @albums ||= Album.find_by_apple_id(apple_id, store)
end

#to_hashObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/itunes_api/music/artist.rb', line 33

def to_hash
  {
    amg_id: amg_id,
    apple_id: apple_id,
    genre: genre,
    link: link,
    name: name,
    store: store
  }
end