| Class | RSS::XML::Element |
| In: |
lib/rss/xml.rb
|
| Parent: | Object |
| attributes | [R] | |
| children | [R] | |
| name | [R] | |
| prefix | [R] | |
| uri | [R] |
# File lib/rss/xml.rb, line 9
9: def initialize(name, prefix=nil, uri=nil, attributes={}, children=[])
10: @name = name
11: @prefix = prefix
12: @uri = uri
13: @attributes = attributes
14: if children.is_a?(String) or !children.respond_to?(:each)
15: @children = [children]
16: else
17: @children = children
18: end
19: end
# File lib/rss/xml.rb, line 37
37: def ==(other)
38: other.kind_of?(self.class) and
39: @name == other.name and
40: @uri == other.uri and
41: @attributes == other.attributes and
42: @children == other.children
43: end
# File lib/rss/xml.rb, line 62
62: def full_name
63: if @prefix
64: "#{@prefix}:#{@name}"
65: else
66: @name
67: end
68: end
# File lib/rss/xml.rb, line 45
45: def to_s
46: rv = "<#{full_name}"
47: attributes.each do |key, value|
48: rv << " #{Utils.html_escape(key)}=\"#{Utils.html_escape(value)}\""
49: end
50: if children.empty?
51: rv << "/>"
52: else
53: rv << ">"
54: children.each do |child|
55: rv << child.to_s
56: end
57: rv << "</#{full_name}>"
58: end
59: rv
60: end