Class: MassiveSitemap::Builder::Index
- Inherits:
-
Base
- Object
- Base
- MassiveSitemap::Builder::Index
show all
- Defined in:
- lib/massive_sitemap/builder/index.rb
Constant Summary
collapse
'sitemapindex'
{
:xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9'
}
Constants inherited
from Base
Base::OPTS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#add, #close!, #init_writer!
Constructor Details
#initialize(writer, options = {}, &block) ⇒ Index
Returns a new instance of Index.
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/massive_sitemap/builder/index.rb', line 13
def initialize(writer, options = {}, &block)
writer.set(:force_overwrite => true)
super(writer, options) do
writer.each do |path, last_modified|
init_writer!
next if writer.current && path.include?(writer.current)
add path, :last_modified => last_modified
end
end
end
|
Class Method Details
.generate(writer, options = {}, &block) ⇒ Object
24
25
26
|
# File 'lib/massive_sitemap/builder/index.rb', line 24
def self.generate(writer, options = {}, &block)
index_url(super, writer)
end
|
.index_url(builder, writer) ⇒ Object
28
29
30
|
# File 'lib/massive_sitemap/builder/index.rb', line 28
def self.index_url(builder, writer)
writer.current && ::File.join(builder.send(:url), writer.current)
end
|
Instance Method Details
#add_url!(location, attrs = {}) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/massive_sitemap/builder/index.rb', line 32
def add_url!(location, attrs = {})
init_writer!
tag! 'sitemap' do
tag! 'loc', location
tag! 'lastmod', attrs[:last_modified].utc.strftime('%Y-%m-%dT%H:%M:%S+00:00') if attrs[:last_modified]
end
end
|