Sha256: 25345fe6a4b720eabfc01d1facaf6c76fc41b82e9338770a271c088847f11713
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 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) if matches and not matches.empty? find(matches.first[:id]) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
musicbrainz-0.8.0 | lib/musicbrainz/models/artist.rb |
musicbrainz-0.7.7 | lib/musicbrainz/models/artist.rb |