Class: XmlDataBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/xml_data_builder.rb

Defined Under Namespace

Classes: CDATA

Instance Method Summary collapse

Constructor Details

#initialize(data, options = {}) ⇒ XmlDataBuilder

Returns a new instance of XmlDataBuilder.



13
14
15
# File 'lib/xml_data_builder.rb', line 13

def initialize(data, options = {})
  @data, @options = data, options
end

Instance Method Details

#documentObject



17
18
19
20
21
22
23
24
# File 'lib/xml_data_builder.rb', line 17

def document
  indent = @options[:indent] || 2
  output = String.new
  xml = Builder::XmlMarkup.new(:target => output, :indent => indent)
  xml.instruct!
  to_xml(xml, @data)
  return output
end