def generate
      sitemaps.group_by(&:folder).each do |folder, sitemaps|
        index_path = "#{DynamicSitemaps.temp_path}/#{folder}/#{DynamicSitemaps.index_file_name}"

        if !DynamicSitemaps.always_generate_index && sitemaps.count == 1 && sitemaps.first.files.count == 1
          file_path = "#{DynamicSitemaps.temp_path}/#{folder}/#{sitemaps.first.files.first}"
          FileUtils.copy file_path, index_path
          File.delete file_path
        else
          File.open(index_path, "w") do |file|
            write_beginning(file)
            write_sitemaps(file, sitemaps)
            write_end(file)
          end
        end
      end
    end
def generate
      sitemaps.group_by(&:folder).each do |folder, sitemaps|
        index_path = "#{DynamicSitemaps.temp_path}/#{folder}/#{DynamicSitemaps.index_file_name}"

        if !DynamicSitemaps.always_generate_index && sitemaps.count == 1 && sitemaps.first.files.count == 1
          file_path = "#{DynamicSitemaps.temp_path}/#{folder}/#{sitemaps.first.files.first}"
          FileUtils.copy file_path, index_path
          File.delete file_path
        else
          File.open(index_path, "w") do |file|
            write_beginning(file)
            write_sitemaps(file, sitemaps)
            write_end(file)
          end
        end
      end
    end
def generate sitemaps . group_by ( :folder ) . each do | folder , sitemaps | index_path = "#{DynamicSitemaps.temp_path}/#{folder}/#{DynamicSitemaps.index_file_name}" if ! DynamicSitemaps . always_generate_index && sitemaps . count == 1 && sitemaps . first . files . count == 1 file_path = "#{DynamicSitemaps.temp_path}/#{folder}/#{sitemaps.first.files.first}" FileUtils . copy file_path , index_path File . delete file_path else File . open ( index_path , "w" ) do | file | write_beginning ( file ) write_sitemaps ( file , sitemaps ) write_end ( file ) end end end end
Array of sitemap results
 Initialize the class with an array of SitemapResult
Array of sitemap results Initialize the class with an array of SitemapResult