class Dmcli::XmlExporter
XmlExporter
Utility class for exporting data to a XML file. Used to compile a large number of individual XML files into one large XML file.
Public Instance Methods
builder( target, output )
click to toggle source
# File lib/dmcli/xml_exporter.rb, line 10 def builder( target, output ) loader = DndDataLoader.new spells = loader.load_spells(target, "BECMI", "any", "any") xml_contents = Nokogiri::XML::Builder.new do |xml| xml.spellList("xmlns" => "dungeon", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation" => "dungeon spells.xsd") do spells.each do |s| xml.spell do xml.name s.name xml.editions do xml.editionBECMI do xml.is_reversible s.is_reversible xml.class_ s.spell_class xml.level s.spell_level xml.range s.range xml.duration s.range xml.effect s.effect xml.description s.description_text xml.sources do xml.source "Dungeons and Dragons Rules Cyclopedia, p42" end end end end end end end puts "Exporting to #{output}" File.open(output, "w") do |f| f.write(xml_contents.to_xml) end filesize = File.size(output) / 1024 puts "#{filesize} kb written" end