Class: MusicBrainz::Artist
Instance Attribute Summary collapse
-
#artist_info ⇒ Object
Returns the value of attribute artist_info.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#release_groups ⇒ Object
Returns the value of attribute release_groups.
-
#releases ⇒ Object
Returns the value of attribute releases.
-
#works ⇒ Object
Returns the value of attribute works.
Instance Method Summary collapse
- #get_info ⇒ Object
- #get_release_groups ⇒ Object
- #get_releases ⇒ Object
- #get_request(method, mbid, query = []) ⇒ Object
- #get_works ⇒ Object
-
#initialize(mbid, query = []) ⇒ Artist
constructor
A new instance of Artist.
Methods inherited from Base
Constructor Details
#initialize(mbid, query = []) ⇒ Artist
Returns a new instance of Artist.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/musicbrainz/artist.rb', line 10 def initialize(mbid, query=[]) #Valid sub-queries: artists, labels, recordings, release-groups @mbid=mbid.is_mbid ? mbid : false if query.present? && query!=[] @query=query.join("+") else @query='releases' end @method='artist' get_request(@method, @mbid, @query) end |
Instance Attribute Details
#artist_info ⇒ Object
Returns the value of attribute artist_info.
6 7 8 |
# File 'lib/musicbrainz/artist.rb', line 6 def artist_info @artist_info end |
#metadata ⇒ Object
Returns the value of attribute metadata.
3 4 5 |
# File 'lib/musicbrainz/artist.rb', line 3 def @metadata end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/musicbrainz/artist.rb', line 4 def name @name end |
#release_groups ⇒ Object
Returns the value of attribute release_groups.
7 8 9 |
# File 'lib/musicbrainz/artist.rb', line 7 def release_groups @release_groups end |
#releases ⇒ Object
Returns the value of attribute releases.
5 6 7 |
# File 'lib/musicbrainz/artist.rb', line 5 def releases @releases end |
#works ⇒ Object
Returns the value of attribute works.
8 9 10 |
# File 'lib/musicbrainz/artist.rb', line 8 def works @works end |
Instance Method Details
#get_info ⇒ Object
31 32 33 |
# File 'lib/musicbrainz/artist.rb', line 31 def get_info @artist_info={:type => @metadata['artist']['type'], :mbid => @metadata['artist']['id']} end |
#get_release_groups ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/musicbrainz/artist.rb', line 43 def get_release_groups release_groups=@metadata['artist']['release_group_list']['release_group'] @release_groups=Array.new release_groups.each do |r| @release_groups<<OpenStruct.new(r) end end |
#get_releases ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/musicbrainz/artist.rb', line 35 def get_releases releases=@metadata['artist']['release_list']['release'] @releases=Array.new releases.each do |r| @releases<<OpenStruct.new(r) end end |
#get_request(method, mbid, query = []) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/musicbrainz/artist.rb', line 22 def get_request(method, mbid, query=[]) @request=self.class.get(method, mbid, query) @metadata=@request['metadata'] get_releases if query.include?('releases') get_info if query.include?('info') get_release_groups if query.include?('release-groups') get_works if query.include?('works') end |
#get_works ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/musicbrainz/artist.rb', line 51 def get_works works=@metadata['artist']['work_list']['work'] @works=Array.new works.each do |r| @works<<OpenStruct.new(r) end end |