instance method
xml_out
Ruby on Rails 2.2.3
Since v2.2.3 Last seen in v2.2.3Signature
xml_out(ref, options = nil)
Converts a data structure into an XML document.
- ref
-
Reference to data structure to be converted into XML.
- options
-
Options to be used.
Parameters
-
refreq -
optionsopt = nil
Source
# File activesupport/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb, line 212
def xml_out(ref, options = nil)
handle_options('out', options)
if ref.instance_of?(Array)
ref = { @options['anonymoustag'] => ref }
end
if @options['keeproot']
keys = ref.keys
if keys.size == 1
ref = ref[keys[0]]
@options['rootname'] = keys[0]
end
elsif @options['rootname'] == ''
if ref.instance_of?(Hash)
refsave = ref
ref = {}
refsave.each { |key, value|
if !scalar(value)
ref[key] = value
else
ref[key] = [ value.to_s ]
end
}
end
end
@ancestors = []
xml = value_to_xml(ref, @options['rootname'], '')
@ancestors = nil
if @options['xmldeclaration']
xml = @options['xmldeclaration'] + "\n" + xml
end
if @options.has_key?('outputfile')
if @options['outputfile'].kind_of?(IO)
return @options['outputfile'].write(xml)
else
File.open(@options['outputfile'], "w") { |file| file.write(xml) }
end
end
xml
end
Defined in activesupport/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb line 212
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in XmlSimple