class XmlTag

Attributes

attributes[RW]
children[RW]
name[RW]

Public Class Methods

new(name) click to toggle source
# File lib/upnp_xml.rb, line 5
def initialize(name)
  @name = name
  @children = []
  @attributes = {}
end

Public Instance Methods

append(tag) click to toggle source
# File lib/upnp_xml.rb, line 13
def append(tag)
  @children.append(tag)
  return tag
end
to_s() click to toggle source
# File lib/upnp_xml.rb, line 18
def to_s
  elems = [@name] + @attributes.map {|k,v| "#{k}=\"#{v}\""}

  if @children.any?
    str = "<#{elems.join(' ')}>"
    str += @children.each {|elem| "#{elem}"}.join("")
    str += "</#{@name}>"
    return str
  else
    return "<#{elems.join(' ')} />"
  end
end