Sha256: b0a78e61014ca50d63ddaa823b9549bee61af6c71ec6e43106baf743080a9cc4

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module SitemapGenerator
  module Builder
    class SitemapIndexFile < SitemapFile

      def initialize(*args)
        super(*args)

        @xml_content = '' # XML urlset content
        @xml_wrapper_start = <<-HTML
          <?xml version="1.0" encoding="UTF-8"?>
            <sitemapindex
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
                http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd"
              xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
            >
        HTML
        @xml_wrapper_start.gsub!(/\s+/, ' ').gsub!(/ *> */, '>').strip!
        @xml_wrapper_end   = %q[</sitemapindex>]
        self.filesize = @xml_wrapper_start.bytesize + @xml_wrapper_end.bytesize
      end

      # Return XML as a String
      def build_xml(builder, link)
        builder.sitemap do
          builder.loc        link[:loc]
          builder.lastmod    w3c_date(link[:lastmod])   if link[:lastmod]
        end
        builder << ''
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sitemap_generator-0.3.3 lib/sitemap_generator/builder/sitemap_index_file.rb
sitemap_generator-0.3.2 lib/sitemap_generator/builder/sitemap_index_file.rb