Class that will build the hash while the XML document is being parsed using SAX events.
# File lib/active_support/xml_mini/libxmlsax.rb, line 20 20: def current_hash 21: @hash_stack.last 22: end
# File lib/active_support/xml_mini/libxmlsax.rb, line 54 54: def on_characters(string) 55: current_hash[CONTENT_KEY] << string 56: end
# File lib/active_support/xml_mini/libxmlsax.rb, line 29 29: def on_end_document 30: @hash = @hash_stack.pop 31: @hash.delete(CONTENT_KEY) 32: end
# File lib/active_support/xml_mini/libxmlsax.rb, line 47 47: def on_end_element(name) 48: if current_hash.length > current_hash.delete(HASH_SIZE_KEY) && current_hash[CONTENT_KEY].blank? || current_hash[CONTENT_KEY] == '' 49: current_hash.delete(CONTENT_KEY) 50: end 51: @hash_stack.pop 52: end
# File lib/active_support/xml_mini/libxmlsax.rb, line 24 24: def on_start_document 25: @hash = { CONTENT_KEY => '' } 26: @hash_stack = [@hash] 27: end
# File lib/active_support/xml_mini/libxmlsax.rb, line 34 34: def on_start_element(name, attrs = {}) 35: new_hash = { CONTENT_KEY => '' }.merge(attrs) 36: new_hash[HASH_SIZE_KEY] = new_hash.size + 1 37: 38: case current_hash[name] 39: when Array then current_hash[name] << new_hash 40: when Hash then current_hash[name] = [current_hash[name], new_hash] 41: when nil then current_hash[name] = new_hash 42: end 43: 44: @hash_stack.push(new_hash) 45: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.