Module: MusicBrainz::Bindings::Artist

Extended by:
Artist
Included in:
Artist
Defined in:
lib/musicbrainz/bindings/artist.rb

Instance Method Summary collapse

Instance Method Details

#parse(xml) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/musicbrainz/bindings/artist.rb', line 4

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