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

24 lines
664 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- encoding : utf-8 -*-
module MusicBrainz
module Bindings
module Artist
def parse(xml)
xml = xml.xpath('./artist')
return {} if xml.empty?
{
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))
end
extend self
end
end
end