Class: EasySitemap::Generator
- Inherits:
-
Object
- Object
- EasySitemap::Generator
- Defined in:
- lib/easy_sitemap/generator.rb
Instance Method Summary collapse
-
#initialize(entities_scope, options = {}) ⇒ Generator
constructor
A new instance of Generator.
- #to_xml ⇒ Object
Constructor Details
#initialize(entities_scope, options = {}) ⇒ Generator
Returns a new instance of Generator.
4 5 6 7 |
# File 'lib/easy_sitemap/generator.rb', line 4 def initialize(entities_scope, = {}) @entities_scope = entities_scope @options = end |
Instance Method Details
#to_xml ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/easy_sitemap/generator.rb', line 9 def to_xml builder = Nokogiri::XML::Builder.new do |xml| xml.urlset do @entities_scope.find_each(batch_size: 1) do |entity| xml.url do xml.loc url(entity) if entity.respond_to?(:updated_at) xml.lastmod entity.updated_at elsif entity.respond_to?(:updated_on) xml.lastmod entity.updated_on end end end end end builder.to_xml end |