method
tag
v1_8_7_72 -
Show latest stable
- Class:
RSS::Element
tag(indent, additional_attrs={}, &block)private
No documentation available.
# File lib/rss/rss.rb, line 978
def tag(indent, additional_attrs={}, &block)
next_indent = indent + INDENT
attrs = collect_attrs
return "" if attrs.nil?
return "" unless have_required_elements?
attrs.update(additional_attrs)
start_tag = make_start_tag(indent, next_indent, attrs.dup)
if block
content = block.call(next_indent)
else
content = []
end
if content.is_a?(String)
content = [content]
start_tag << ">"
end_tag = "</#{full_name}>"
else
content = content.reject{|x| x.empty?}
if content.empty?
return "" if attrs.empty?
end_tag = "/>"
else
start_tag << ">\n"
end_tag = "\n#{indent}</#{full_name}>"
end
end
start_tag + content.join("\n") + end_tag
end