2011-10-06 15:31:17 +04:00
|
|
|
module MusicBrainz
|
|
|
|
class Base
|
|
|
|
def self.safe_get_attr xml, path, name
|
2011-10-06 16:30:46 +04: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 15:31:17 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.safe_get_value xml, path
|
|
|
|
xml.css(path).first.text unless xml.css(path).empty?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|