1
0
Fork 0
musicbrainz/lib/musicbrainz/base.rb

18 lines
449 B
Ruby
Raw Normal View History

# -*- encoding: utf-8 -*-
2011-10-06 11:31:17 +00:00
module MusicBrainz
class Base
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
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
def self.load(*args)
MusicBrainz::Tools::Proxy.load(*args)
end
2011-10-06 11:31:17 +00:00
end
end