class Estatic::Category
Attributes
products[RW]
subcategories[RW]
Public Class Methods
new(name, subcategories = [])
click to toggle source
Calls superclass method
# File lib/estatic/category.rb, line 5 def initialize(name, subcategories = []) super(name) @subcategories = subcategories.map { |subcategory| Subcategory.new(subcategory, name) } @products = get_products end
Public Instance Methods
directory()
click to toggle source
# File lib/estatic/category.rb, line 24 def directory File.join(Estatic.configuration.estatic_site_path, name) end
get_products()
click to toggle source
# File lib/estatic/category.rb, line 15 def get_products if has_subcategories? subcategories.map(&:products).flatten else products = CSVParser.parse(name) products.map { |attributes| OpenStruct.new product(attributes) } end end
has_subcategories?()
click to toggle source
# File lib/estatic/category.rb, line 11 def has_subcategories? subcategories.any? end
root_path()
click to toggle source
# File lib/estatic/category.rb, line 28 def root_path '../'.freeze end