Class: SitemapGenerator::Builder::SitemapIndexUrl

Inherits:
SitemapUrl
  • Object
show all
Defined in:
lib/sitemap_generator/builder/sitemap_index_url.rb

Instance Method Summary collapse

Methods inherited from SitemapUrl

#news?

Constructor Details

#initialize(path, options = {}) ⇒ SitemapIndexUrl

Returns a new instance of SitemapIndexUrl



7
8
9
10
11
12
13
14
15
# File 'lib/sitemap_generator/builder/sitemap_index_url.rb', line 7

def initialize(path, options={})
  if index = path.is_a?(SitemapGenerator::Builder::SitemapIndexFile) && path
    options = 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

Instance Method Details

#to_xml(builder = nil) ⇒ Object

Return the URL as XML



18
19
20
21
22
23
24
25
# File 'lib/sitemap_generator/builder/sitemap_index_url.rb', line 18

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