Sha256: dd73de5a52992f20ad1da93d51379f468c870be51d2eb0f168870578ad7b3a6e
Contents?: true
Size: 684 Bytes
Versions: 15
Compression:
Stored size: 684 Bytes
Contents
module SAXMachine class NSStack < Hash def initialize(parent=nil, attrs=[]) # Initialize super() @parent = parent # Parse attributes attrs.each do |attr| if attr.kind_of?(Array) k, v = attr case k when 'xmlns' then self[''] = v when /^xmlns:(.+)/ then self[$1] = v end end end end # Lookup def [](name) if (ns = super(name.to_s)) # I've got it ns elsif @parent # Parent may have it @parent[name] else # Undefined, empty namespace '' end end def pop @parent end end end
Version data entries
15 entries across 15 versions & 3 rubygems