Class: Estatic::ProductListingsPage

Inherits:
Page
  • Object
show all
Defined in:
lib/estatic/product_listings_page.rb

Instance Attribute Summary collapse

Attributes inherited from Page

#resource

Instance Method Summary collapse

Methods inherited from Page

#content

Constructor Details

#initialize(resource, page_number) ⇒ ProductListingsPage

Returns a new instance of ProductListingsPage.



5
6
7
8
9
10
# File 'lib/estatic/product_listings_page.rb', line 5

def initialize(resource, page_number)
  super(resource)
  @products = resource.products_in_chunks[page_number - 1]
  @current_page = page_number
  @total_pages = resource.total_chunks
end

Instance Attribute Details

#current_pageObject (readonly)

Returns the value of attribute current_page.



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

def current_page
  @current_page
end

#productsObject (readonly)

Returns the value of attribute products.



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

def products
  @products
end

#total_pagesObject (readonly)

Returns the value of attribute total_pages.



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

def total_pages
  @total_pages
end

Instance Method Details

#filenameObject



12
13
14
# File 'lib/estatic/product_listings_page.rb', line 12

def filename
  current_page == 1 ? 'index.html' : "#{current_page}.html"
end

#render(filename, args = {}) ⇒ Object



16
17
18
19
# File 'lib/estatic/product_listings_page.rb', line 16

def render(filename, args = {})
  partial = Dir.glob("#{Estatic.configuration.project_path}/blueprints/shared/#{filename}.{erb,haml,slim}").first
  Tilt.new(partial).render(nil, args[:locals])
end