Sha256: f4e2e2fb5e30b784ede26ab3e04f4dea20051ff81ada47d5bc70941d5a8e8fc1
Contents?: true
Size: 1 KB
Versions: 2
Compression:
Stored size: 1 KB
Contents
module MusicBrainz class Artist < BaseModel field :id, String field :type, String field :name, String field :country, String field :date_begin, Date field :date_end, Date field :urls, Hash 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 class << self def find(id) client.load(:artist, { id: id, inc: [:url_rels] }, { binding: :artist, create_model: :artist }) end def search(name) super({artist: name}) end def discography(mbid) artist = find(mbid) artist.release_groups.each { |rg| rg.releases.each { |r| r.tracks } } artist end def find_by_name(name) matches = search(name) matches.empty? ? nil : find(matches.first[:id]) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
musicbrainz-0.7.6 | lib/musicbrainz/models/artist.rb |
musicbrainz-0.7.5 | lib/musicbrainz/models/artist.rb |