2012-07-04 13:10:47 +00:00
|
|
|
# -*- encoding: utf-8 -*-
|
2011-10-06 11:31:17 +00:00
|
|
|
module MusicBrainz
|
|
|
|
class Base
|
2012-07-04 13:10:47 +00:00
|
|
|
def self.safe_get_attr(xml, path, name)
|
2011-10-06 12:30:46 +00:00
|
|
|
node = path.nil? ? xml : (xml.css(path).first unless xml.css(path).empty?)
|
|
|
|
node.attr(name) unless node.nil? or node.attr(name).nil?
|
2011-10-06 11:31:17 +00:00
|
|
|
end
|
2012-07-04 13:10:47 +00:00
|
|
|
|
|
|
|
def self.safe_get_value(xml, path)
|
2011-10-06 11:31:17 +00:00
|
|
|
xml.css(path).first.text unless xml.css(path).empty?
|
|
|
|
end
|
2012-07-04 13:10:47 +00:00
|
|
|
|
|
|
|
def self.load(*args)
|
|
|
|
MusicBrainz::Tools::Proxy.load(*args)
|
|
|
|
end
|
2011-10-06 11:31:17 +00:00
|
|
|
end
|
|
|
|
end
|