lib/xbel.rb in xbel-0.2.1 vs lib/xbel.rb in xbel-0.2.2

- old
+ new

@@ -5,24 +5,29 @@ class XBEL < Nokogiri::XML::Document extend Forwardable def_delegators :root, :title, :title=, :desc, :desc= + # Returns an instance of XBEL. def self.new(major = 1, minor = 0) parse %Q'<!DOCTYPE xbel PUBLIC "+//IDN python.org//DTD XML Bookmark Exchange Language 1.0//EN//XML" "http://www.python.org/topics/xml/dtds/xbel-1.0.dtd"><xbel version="%i.%i"></xbel>' % [major, minor] end - def self.open(path) - parse File.read(path.to_s) + # Reads file at <tt>path</tt> into <tt>parse</tt>. + # @yield [XBEL] + # @see Nokogiri.parse + def self.open(path, &block) + parse File.read(path.to_s), &block end - # Use <tt>XBEL.parse(string)</tt> create an instance. + # Calls <tt>Nokogiri#initialize</tt> and decorates XBEL nodes. def initialize(*args) super decorators(Nokogiri::XML::Node) << Nokogiri::Decorators::XBEL decorate! end + # Returns node with given <tt>id</tt>. def [](id) root.at("//*[@id='#{ id }']") end # Returns an array of version numbers.