Class: MusicBrainzArtist
- Inherits:
-
Object
- Object
- MusicBrainzArtist
- Defined in:
- lib/models/music_brainz_artist.rb
Instance Attribute Summary collapse
-
#country ⇒ Object
Returns the value of attribute country.
-
#date_begin ⇒ Object
Returns the value of attribute date_begin.
-
#date_end ⇒ Object
Returns the value of attribute date_end.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#country ⇒ Object
Returns the value of attribute country.
2 3 4 |
# File 'lib/models/music_brainz_artist.rb', line 2 def country @country end |
#date_begin ⇒ Object
Returns the value of attribute date_begin.
2 3 4 |
# File 'lib/models/music_brainz_artist.rb', line 2 def date_begin @date_begin end |
#date_end ⇒ Object
Returns the value of attribute date_end.
2 3 4 |
# File 'lib/models/music_brainz_artist.rb', line 2 def date_end @date_end end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/models/music_brainz_artist.rb', line 2 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/models/music_brainz_artist.rb', line 2 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
2 3 4 |
# File 'lib/models/music_brainz_artist.rb', line 2 def type @type end |
Class Method Details
.find(mbid) ⇒ Object
15 16 17 |
# File 'lib/models/music_brainz_artist.rb', line 15 def self.find mbid @artist = self.parse_xml(Nokogiri::XML(open('http://musicbrainz.org/ws/2/artist/' + mbid))) end |
.parse_xml(xml) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/models/music_brainz_artist.rb', line 19 def self.parse_xml xml @artist = MusicBrainzArtist.new @artist.id = xml.css('artist').attr('id').value @artist.type = xml.css('artist').attr('type').value @artist.name = xml.css('artist > name').text @artist.country = xml.css('artist > country').text || nil @artist.date_begin = xml.css('artist > life-span > begin').text || nil @artist.date_end = xml.css('artist > life-span > end').text || nil @artist end |
Instance Method Details
#release_groups ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/models/music_brainz_artist.rb', line 5 def release_groups if @release_groups.nil? and not self.id.nil? @release_groups = [] Nokogiri::XML(open('http://musicbrainz.org/ws/2/release-group/?artist=' + self.id)).css('release-group').each do |rg| @release_groups << MusicBrainzReleaseGroup.parse_xml(rg) end end @release_groups end |