module RSS::Maker::AtomTextConstructBase::EnsureXMLContent - rss: Ruby Standard Library Documentation

# module RSS::Maker::AtomTextConstructBase::EnsureXMLContent

### Public Class Methods

included(base) click to toggle source
Calls superclass method

    # File rss-0.3.1/lib/rss/maker/base.rb, line 295
    def included(base)
      super
      base.class_eval do
        %w(type content xml_content).each do |element|
          attr_reader element
          attr_writer element if element != "xml_content"
          add_need_initialize_variable(element)
        end

        alias_method(:xhtml, :xml_content)
      end
    end

### Public Instance Methods

ensure_xml_content(content) click to toggle source

    # File rss-0.3.1/lib/rss/maker/base.rb, line 309
    def ensure_xml_content(content)
      xhtml_uri = ::RSS::Atom::XHTML_URI
      unless content.is_a?(RSS::XML::Element) and
          ["div", xhtml_uri] == [content.name, content.uri]
        children = content
        children = [children] unless content.is_a?(Array)
        children = set_xhtml_uri_as_default_uri(children)
        content = RSS::XML::Element.new("div", nil, xhtml_uri,
                                        {"xmlns" => xhtml_uri},
                                        children)
      end
      content
    end

xhtml=(content) click to toggle source

    # File rss-0.3.1/lib/rss/maker/base.rb, line 327
    def xhtml=(content)
      self.xml_content = content
    end

xml_content=(content) click to toggle source

    # File rss-0.3.1/lib/rss/maker/base.rb, line 323
    def xml_content=(content)
      @xml_content = ensure_xml_content(content)
    end

### Private Instance Methods

set_xhtml_uri_as_default_uri(children) click to toggle source

    # File rss-0.3.1/lib/rss/maker/base.rb, line 332
    def set_xhtml_uri_as_default_uri(children)
      children.collect do |child|
        if child.is_a?(RSS::XML::Element) and
            child.prefix.nil? and child.uri.nil?
          RSS::XML::Element.new(child.name, nil, ::RSS::Atom::XHTML_URI,
                                child.attributes.dup,
                                set_xhtml_uri_as_default_uri(child.children))
        else
          child
        end
      end
    end