Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Quick refactor, courtesy of Jared Kuolt.
Browse files Browse the repository at this point in the history
  • Loading branch information
codahale committed Aug 5, 2008
1 parent ac3f6c6 commit 565bd69
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/faster_builder/xml_markup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FasterBuilder::XmlMarkup < BlankSlate
def initialize(options = {})
# TODO: add indentation support, if possible
@options = options
@nodes = [nil]
@nodes = []
@current_node = nil
end

Expand All @@ -34,8 +34,6 @@ def instruct!(type = :xml, attrs = {})
encoding = attrs[:encoding] || "UTF-8"
@doc = XML::Document.new(version)
@doc.encoding = encoding
@nodes[0] = @doc
@instructed = true
end

def cdata!(data)
Expand Down Expand Up @@ -92,11 +90,7 @@ def tag!(element, *options, &block)
end

def target!
if @instructed
return @nodes.map { |n| n.to_s }.join("")
else
return @nodes[1..-1].map { |n| n.to_s }.join("")
end
return (@doc.nil? ? @nodes : [@doc] + @nodes).map { |n| n.to_s }.join("")
end

def text!(text)
Expand Down

0 comments on commit 565bd69

Please sign in to comment.