Sha256: 93b10c1a0e7fe2d3ee5831a874433ad78cc4fc4660d0c0b632caed21aa7195d6
Contents?: true
Size: 1.84 KB
Versions: 1
Compression:
Stored size: 1.84 KB
Contents
module Nokogiri::Decorators::XBEL module Folder include Entry # Returns an instance of NodeSet with all valid children for this folder. def entries xpath './alias', './bookmark', './folder', './separator' end # Returns an instance of NodeSet with all aliases for this folder. def aliases xpath './alias' end # Returns an instance of NodeSet with all bookmarks for this folder. def bookmarks xpath './bookmark' end # Returns an instance of NodeSet with all folders for this folder. def folders xpath './folder' end # Returns true. def folder? true end # Adds a entry and sets added attribute. def add_child(node) node.added = Date.today if node.is_a? Entry super end # Builds a bookmark with given attributes and add it. def build_bookmark(title, attributes = {}, &block) node = Nokogiri::XML::Node.new('bookmark', document) assign_to node, attributes.merge('title' => title) add_child node end # Builds a folder with given attributes and add it. def build_folder(title, attributes = {}, &block) node = Nokogiri::XML::Node.new('folder', document) assign_to node, attributes.merge('title' => title) add_child node end # Builds an alias with given attributes and add it. def build_alias(ref) node = Nokogiri::XML::Node.new('alias', document) node.ref = (Entry === ref) ? ref.id : ref.to_s add_child node end # Builds a seperator with given attributes and add it. def add_seperator add_child Nokogiri::XML::Node.new('separator', document) end protected def assign_to(node, attributes) #:nodoc: attributes.each do |key, value| node.send "#{ key }=", value end yield node if block_given? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xbel-0.2.0 | lib/nokogiri/decorators/xbel/folder.rb |