Skip to content

Commit

Permalink
White space cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jimweirich committed Sep 6, 2012
1 parent cae2f70 commit a20f0a9
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/builder/xmlbase.rb
Expand Up @@ -10,11 +10,11 @@ class IllegalBlockError < RuntimeError; end
# XmlBase is a base class for building XML builders. See
# Builder::XmlMarkup and Builder::XmlEvents for examples.
class XmlBase < BlankSlate

class << self
attr_accessor :cache_method_calls
end

# Create an XML markup builder.
#
# out:: Object receiving the markup. +out+ must respond to
Expand All @@ -30,7 +30,7 @@ def initialize(indent=0, initial=0, encoding='utf-8')
@level = initial
@encoding = encoding.downcase
end

# Create a tag named +sym+. Other than the first argument which
# is the tag name, the arguments are the same as the tags
# implemented via <tt>method_missing</tt>.
Expand Down Expand Up @@ -77,7 +77,7 @@ def tag!(sym, *args, &block)
end
@target
end

# Create XML markup based on the name of the method. This method
# is never invoked directly, but is called for each markup method
# in the markup block that isn't cached.
Expand All @@ -93,7 +93,7 @@ def method_missing(sym, *args, &block)
def text!(text)
_text(_escape(text))
end

# Append text to the output target without escaping any markup.
# May be used within the markup brackets as:
#
Expand All @@ -110,7 +110,7 @@ def text!(text)
def <<(text)
_text(text)
end

# For some reason, nil? is sent to the XmlMarkup object. If nil?
# is not defined and method_missing is invoked, some strange kind
# of recursion happens. Since nil? won't ever be an XML tag, it
Expand All @@ -122,7 +122,7 @@ def nil?
end

private

require 'builder/xchar'
if ::String.method_defined?(:encode)
def _escape(text)
Expand Down Expand Up @@ -150,12 +150,12 @@ def _newline
return if @indent == 0
text! "\n"
end

def _indent
return if @indent == 0 || @level == 0
text!(" " * (@level * @indent))
end

def _nested_structures(block)
@level += 1
block.call(self)
Expand All @@ -177,7 +177,7 @@ def #{sym.to_s}(*args, &block)
NEW_METHOD
end
end

XmlBase.cache_method_calls = true
end

end

0 comments on commit a20f0a9

Please sign in to comment.