Class: SitemapGen::CSV
- Inherits:
-
Object
- Object
- SitemapGen::CSV
- Defined in:
- lib/sitemap_gen/csv.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(dir_path, base_url, save_path) ⇒ CSV
constructor
A new instance of CSV.
Constructor Details
#initialize(dir_path, base_url, save_path) ⇒ CSV
Returns a new instance of CSV.
3 4 5 6 7 8 9 10 11 |
# File 'lib/sitemap_gen/csv.rb', line 3 def initialize(dir_path, base_url, save_path) @dir_path = dir_path @base_url = base_url @save_path = save_path || Dir.pwd @max_level = 1 @html_files = Dir.glob("#{dir_path}/**/index.html").sort_by { |f| File.dirname(f) } raise 'There is no index.html files in your directory' if @html_files.empty? @sitemaps = create_sitemaps end |
Instance Method Details
#execute ⇒ Object
13 14 15 16 17 18 |
# File 'lib/sitemap_gen/csv.rb', line 13 def execute ::CSV.open("#{@save_path}/sitemap.csv", 'wb') do |csv| csv << csv_header @sitemaps.each_with_index { |item, i| csv << csv_row(item, i) } end end |