Class: Estatic::Subcategory
- Defined in:
- lib/estatic/subcategory.rb
Instance Attribute Summary collapse
-
#category_name ⇒ Object
readonly
Returns the value of attribute category_name.
-
#products ⇒ Object
readonly
Returns the value of attribute products.
Attributes inherited from Resource
Instance Method Summary collapse
- #directory ⇒ Object
- #get_products ⇒ Object
- #has_subcategories? ⇒ Boolean
-
#initialize(name, category_name) ⇒ Subcategory
constructor
A new instance of Subcategory.
- #root_path ⇒ Object
Methods inherited from Resource
#get_locals, #products_in_chunks, #proper_name, #total_chunks
Constructor Details
#initialize(name, category_name) ⇒ Subcategory
Returns a new instance of Subcategory.
5 6 7 8 9 |
# File 'lib/estatic/subcategory.rb', line 5 def initialize(name, category_name) super(name) @category_name = category_name @products = get_products end |
Instance Attribute Details
#category_name ⇒ Object (readonly)
Returns the value of attribute category_name.
3 4 5 |
# File 'lib/estatic/subcategory.rb', line 3 def category_name @category_name end |
#products ⇒ Object (readonly)
Returns the value of attribute products.
3 4 5 |
# File 'lib/estatic/subcategory.rb', line 3 def products @products end |
Instance Method Details
#directory ⇒ Object
20 21 22 |
# File 'lib/estatic/subcategory.rb', line 20 def directory File.join(Estatic.configuration.estatic_site_path, category_name, name) end |
#get_products ⇒ Object
15 16 17 18 |
# File 'lib/estatic/subcategory.rb', line 15 def get_products products = CSVParser.parse(name) products.map { |attributes| OpenStruct.new product(attributes) } end |
#has_subcategories? ⇒ Boolean
11 12 13 |
# File 'lib/estatic/subcategory.rb', line 11 def has_subcategories? false end |
#root_path ⇒ Object
24 25 26 |
# File 'lib/estatic/subcategory.rb', line 24 def root_path '../../'.freeze end |