Skip to content

Instantly share code, notes, and snippets.

tmp
log
doc
daemon
*.swp
# USAGE: Hash.from_xml:(YOUR_XML_STRING)
require 'nokogiri'
# modified from http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash/1231297#1231297
class Hash
class << self
def from_xml(xml_io)
begin
result = Nokogiri::XML(xml_io)
return { result.root.name.to_sym => xml_node_to_hash(result.root)}
class Dungeon
@@levels = []
def add_level(n, h, w)
@@levels[n] = Level.new(h, w)
end
end
class Level
def initialize(height, width)
@height, @width = height, width