Class: SitemapGenerator::SitemapIndexLocation

Inherits:
SitemapLocation show all
Defined in:
lib/sitemap_generator/sitemap_location.rb

Overview

SitemapLocation subclass for the sitemap index file. Defaults the namer to :sitemap (no numeric suffix on the first name) and exposes the create_index option.

Constant Summary

Constants inherited from SitemapLocation

SitemapGenerator::SitemapLocation::PATH_OUTPUT_WIDTH

Constants included from Helpers::NumberHelper

Helpers::NumberHelper::DECIMAL_UNITS, Helpers::NumberHelper::STORAGE_UNITS

Instance Method Summary collapse

Methods inherited from SitemapLocation

#[]=, #content_type, #directory, #filename, #filesize, #gzip?, #namer, #path, #path_in_public, #reserve_name, #reserved_name?, #url, #verbose?, #with, #write

Methods included from Helpers::NumberHelper

#number_to_human_size, #number_with_delimiter, #number_with_precision

Constructor Details

#initialize(opts = {}) ⇒ SitemapIndexLocation

Returns a new instance of SitemapIndexLocation.



194
195
196
197
# File 'lib/sitemap_generator/sitemap_location.rb', line 194

def initialize(opts = {})
  opts[:namer] = SitemapGenerator::SimpleNamer.new(:sitemap) if !opts[:filename] && !opts[:namer]
  super
end

Instance Method Details

#create_indexObject

Whether to create a sitemap index. Default :auto. See LinkSet::create_index= for possible values.

A placeholder for an option which should really go into some kind of options class.



204
205
206
# File 'lib/sitemap_generator/sitemap_location.rb', line 204

def create_index
  self[:create_index]
end

#summary(link_count) ⇒ Object

Return a summary string



209
210
211
212
213
214
# File 'lib/sitemap_generator/sitemap_location.rb', line 209

def summary(link_count)
  filesize = number_to_human_size(self.filesize)
  width = self.class::PATH_OUTPUT_WIDTH - 3
  path = SitemapGenerator::Utilities.ellipsis(path_in_public, width)
  "+ #{format("%-#{width}s", path)} #{format('%10s', link_count)} sitemaps / #{format('%10s', filesize)}"
end