Sha256: d606454127ca3616dfeeff48a4b19dcb8838de4bede52613363035f64bb91e71

Contents?: true

Size: 1.82 KB

Versions: 3

Compression:

Stored size: 1.82 KB

Contents

# = xmlbuilder.rb
#
# == Copyright (c) 2006 Thomas Sawyer
#
#   Ruby License
#
#   This module is free software. You may use, modify, and/or redistribute this
#   software under the same terms as Ruby.
#
#   This program is distributed in the hope that it will be useful, but WITHOUT
#   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
#   FOR A PARTICULAR PURPOSE.
#
# == Author(s)
#
# * Thomas Sawyer

# Author::    Thomas Sawyer
# Copyright:: Copyright (c) 2006 Thomas Sawyer
# License::   Ruby License

require 'facets/more/buildingblock.rb'
require 'facets/more/xmlhelper.rb'

# = XMLBuilder
#
# XMLBuilder follows the <em>Builder Pattern</em> allowing XML markup to be
# constructed via Ruby method calls and block structures. XMLBuilder is
# a subclass of BuilderObject --see BuilderObject for more details.

class XMLBuilder < BuildingBlock

  def initialize
    super(XMLHelper, :element)
  end

end


#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCXMLBuilder < Test::Unit::TestCase

    def test_01
      x = XMLBuilder.new
      doc = x.html {
        head {
          title "Test"
        }
        body {
          p "Hello"
          _text "Test"
        }
      }
      r = "<html><head><title>Test</title></head><body><p>Hello</p>Test</body></html>"
      assert_equal( r, doc )
      assert_equal( r, x.to_s )
    end

    #def tes_explicit
    #  x = XMLBuilder.new(true)
    #  doc = x.html {
    #    x.head {
    #      x.title "Test"
    #    }
    #    x.body {
    #      x.p "Hello"
    #      x << text("Test")
    #    }
    #  }
    #  r = "<html><head><title>Test</title></head><body><p>Hello</p>Test</body></html>"
    #  assert_equal( r, doc )
    #  assert_equal( r, x.to_s )
    #end

  end

=end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-1.8.0 lib/facets/more/xmlbuilder.rb
facets-1.8.20 lib/facets/more/xmlbuilder.rb
facets-1.8.8 lib/facets/more/xmlbuilder.rb