Class: TaliaUtil::Xml::BaseBuilder
- Inherits:
-
Object
- Object
- TaliaUtil::Xml::BaseBuilder
- Defined in:
- lib/talia_util/xml/base_builder.rb
Overview
Base class for builders that create XML representations. This uses a Builder::XmlMarkup object in the background which does the actual XML writing.
All builders will be used through the #open method, which can be passed either a Builder::XmlMarkup object, or the options to create one.
Subclasses must provide a build_structure method that creates the outer structure of the XML
Direct Known Subclasses
TaliaCore::ActiveSourceParts::Xml::SourceBuilder, RdfBuilder
Class Method Summary collapse
-
.make_xml_string ⇒ Object
Builds to a string, using a default builder.
-
.open(options) ⇒ Object
Creates a new builder.
Class Method Details
.make_xml_string ⇒ Object
Builds to a string, using a default builder. This returns the string and otherwise works like #open
27 28 29 30 31 32 33 34 |
# File 'lib/talia_util/xml/base_builder.rb', line 27 def self.make_xml_string xml = '' open(:target => xml, :indent => 2) do |builder| yield(builder) end xml end |
.open(options) ⇒ Object
Creates a new builder. The options are equivalent for the options of the underlying Xml builder. The builder itself will be passed to the block that is called by this method. If you pass a :builder option instead, it will use the given builder instead of creating a new one
18 19 20 21 22 23 |
# File 'lib/talia_util/xml/base_builder.rb', line 18 def self.open() my_builder = self.new() my_builder.send(:build_structure) do yield(my_builder) end end |