Class: N::XmlBuilder

Inherits:
Object show all
Includes:
XmlBuilderMixin
Defined in:
lib/nitro/builders/xml.rb

Overview

A class that encapsulats the XML generation functionality. Utilizes duck typing to redirect output to a target buffer.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XmlBuilderMixin

#comment, #end_tag, #method_missing, #start_tag, #text

Constructor Details

#initialize(target = '') ⇒ XmlBuilder

Returns a new instance of XmlBuilder.



96
97
98
# File 'lib/nitro/builders/xml.rb', line 96

def initialize(target = '')
	@target = target
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class N::XmlBuilderMixin

Instance Attribute Details

#targetObject

The target receives the generated xml, should respond_to :<<



94
95
96
# File 'lib/nitro/builders/xml.rb', line 94

def target
  @target
end

Instance Method Details

#<<(str) ⇒ Object



100
101
102
# File 'lib/nitro/builders/xml.rb', line 100

def << (str)
	@target << str
end

#to_sObject



104
105
106
# File 'lib/nitro/builders/xml.rb', line 104

def to_s
	@target.to_s
end