Sha256: d2b690603c2a36fe733879e7802a98ce05d9c1a7766b6804c65df39184e2bb07

Contents?: true

Size: 848 Bytes

Versions: 1

Compression:

Stored size: 848 Bytes

Contents

require 'builder'

module SitemapGenerator
  module Builder
    class SitemapIndexUrl < SitemapUrl

      def initialize(path, options={})
        if index = path.is_a?(SitemapGenerator::Builder::SitemapIndexFile) && path
          SitemapGenerator::Utilities.reverse_merge!(options, :host => index.location.host, :lastmod => Time.now, :changefreq => 'always', :priority => 1.0)
          path = index.location.path_in_public
          super(path, options)
        else
          super
        end
      end

      # Return the URL as XML
      def to_xml(builder=nil)
        builder = ::Builder::XmlMarkup.new if builder.nil?
        builder.sitemap do
          builder.loc        self[:loc]
          builder.lastmod    w3c_date(self[:lastmod])   if self[:lastmod]
        end
        builder << '' # force to string
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sitemap_generator-3.0.0 lib/sitemap_generator/builder/sitemap_index_url.rb