Class: Estatic::Subcategory

Inherits:
Resource show all
Defined in:
lib/estatic/subcategory.rb

Instance Attribute Summary collapse

Attributes inherited from Resource

#locals, #name

Instance Method Summary collapse

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_nameObject (readonly)

Returns the value of attribute category_name.



3
4
5
# File 'lib/estatic/subcategory.rb', line 3

def category_name
  @category_name
end

#productsObject (readonly)

Returns the value of attribute products.



3
4
5
# File 'lib/estatic/subcategory.rb', line 3

def products
  @products
end

Instance Method Details

#directoryObject



20
21
22
# File 'lib/estatic/subcategory.rb', line 20

def directory
  File.join(Estatic.configuration.estatic_site_path, category_name, name)
end

#get_productsObject



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

Returns:

  • (Boolean)


11
12
13
# File 'lib/estatic/subcategory.rb', line 11

def has_subcategories?
  false
end

#root_pathObject



24
25
26
# File 'lib/estatic/subcategory.rb', line 24

def root_path
  '../../'.freeze
end