Sha256: 162e018291ffa4965e72d4a026c9edcd6e88e554d56eb85e08816c5f24ea5e24

Contents?: true

Size: 556 Bytes

Versions: 1

Compression:

Stored size: 556 Bytes

Contents

class Hash

  def tokens_for_xmlize(tag, attributes = {})
    attr_tokens = []
    other_tokens = []
    tag ||= 'object'
    (self.merge(attributes)).each do |k, v|
      if (k == :tag)
        tag = v
      elsif (k == :innerHTML)
        other_tokens.push(['TEXT', v])
      elsif (k.to_s[0..0] == '@')
        attr_tokens.push(['ATTR', k.to_s[1..-1], v])
      else
        other_tokens = other_tokens.concat(v.tokens_for_xmlize(k))
      end
    end
    [['START', tag]] + attr_tokens + other_tokens + [['END', tag]]
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xmlize-0.1.1 lib/xmlize/hash.rb