1
0
Fork 0
musicbrainz/lib/musicbrainz/bindings/artist.rb

24 lines
664 B
Ruby
Raw Normal View History

# -*- encoding : utf-8 -*-
2012-10-12 12:45:51 +00:00
module MusicBrainz
module Bindings
module Artist
def parse(xml)
xml = xml.xpath('./artist')
return {} if xml.empty?
2012-10-12 12:45:51 +00:00
{
id: (xml.attribute('id').value rescue nil),
type: (xml.attribute('type').value rescue nil),
name: (xml.xpath('./name').text.gsub(/[`]/, "'") rescue nil),
country: (xml.xpath('./country').text rescue nil),
date_begin: (xml.xpath('./life-span/begin').text rescue nil),
date_end: (xml.xpath('./life-span/end').text rescue nil)
}.merge(Relations.parse(xml))
2012-10-12 12:45:51 +00:00
end
extend self
end
end
end