Sha256: f4256dd12ef170fa0d16865c53c241d921ef87667ddd8b25c4da5a0a7b9d5f57

Contents?: true

Size: 972 Bytes

Versions: 1

Compression:

Stored size: 972 Bytes

Contents

module DynamicSitemaps
  class Sitemap
    attr_reader :name, :collection, :block, :host, :folder

    # Initializes a sitemap object.
    # 
    #   Sitemap.new(:site) do
    #     url root_url
    #   end
    # 
    # Using an ActiveRecord relation:
    # 
    #   Sitemap.new(:site, Product.visible) do |product|
    #     url product
    #     url product_editions_path(product)
    #   end
    
    def initialize(*args, &block)
      if args.first.is_a?(Symbol)
        @name = args.shift
      end

      if args.last.is_a?(Hash)
        options = args.pop
        @per_page = options[:per_page]
        @host = options[:host]
        @folder = options[:folder]
        @collection = options[:collection]
      end

      @block = block
    end

    def root_url
      "http://#{host}"
    end

    def per_page
      @per_page ||= DynamicSitemaps::DEFAULT_PER_PAGE
    end

    # Generates sitemap XML files based on this sitemap
    def generate
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dynamic_sitemaps-2.0.0.beta lib/dynamic_sitemaps/sitemap.rb