Class: MusicBrainz::Artist

Inherits:
BaseModel show all
Defined in:
lib/musicbrainz/models/artist.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

inherited

Class Method Details

.discography(mbid) ⇒ Object


32
33
34
35
36
# File 'lib/musicbrainz/models/artist.rb', line 32

def discography(mbid)
  artist = find(mbid)
  artist.release_groups.each { |rg| rg.releases.each { |r| r.tracks } }
  artist
end

.find(id) ⇒ Object


21
22
23
24
25
26
# File 'lib/musicbrainz/models/artist.rb', line 21

def find(id)
  client.load(:artist, { id: id, inc: [:url_rels] }, {
    binding: :artist,
    create_model: :artist
  })
end

.find_by_name(name) ⇒ Object


38
39
40
41
42
43
# File 'lib/musicbrainz/models/artist.rb', line 38

def find_by_name(name)
  matches = search(name)
  if matches and not matches.empty?
    find(matches.first[:id])
  end
end

.search(name) ⇒ Object


28
29
30
# File 'lib/musicbrainz/models/artist.rb', line 28

def search(name)
				super({artist: name})
end

Instance Method Details

#release_groupsObject


12
13
14
15
16
17
18
# File 'lib/musicbrainz/models/artist.rb', line 12

def release_groups
  @release_groups ||= client.load(:release_group, { artist: id, inc: [:url_rels] }, {
    binding: :artist_release_groups,
    create_models: :release_group,
    sort: :first_release_date
  }) unless @id.nil?
end