class Nokogiri::XML::Builder
def initialize(options = {}, root = nil, &block)
...
Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
Building a document with a particular encoding for example:
Document that is being built.
Create a new Builder object. +options+ are sent to the top level
##
def initialize(options = {}, root = nil, &block) if root @doc = root.document @parent = root else klassname = "::" + (self.class.name.split("::")[0..-2] + ["Document"]).join("::") klass = begin Object.const_get(klassname) rescue NameError Nokogiri::XML::Document end @parent = @doc = klass.new end @context = nil @arity = nil @ns = nil options.each do |k, v| @doc.send(:"#{k}=", v) end return unless block_given? @arity = block.arity if @arity <= 0 @context = eval("self", block.binding) instance_eval(&block) else yield self end @parent = @doc end