Class: Estatic::ProductListingsPage
- Defined in:
- lib/estatic/product_listings_page.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#products ⇒ Object
readonly
Returns the value of attribute products.
-
#total_pages ⇒ Object
readonly
Returns the value of attribute total_pages.
Attributes inherited from Page
Instance Method Summary collapse
- #filename ⇒ Object
-
#initialize(resource, page_number) ⇒ ProductListingsPage
constructor
A new instance of ProductListingsPage.
- #render(filename, args = {}) ⇒ Object
Methods inherited from Page
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_page ⇒ Object (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 |
#products ⇒ Object (readonly)
Returns the value of attribute products.
3 4 5 |
# File 'lib/estatic/product_listings_page.rb', line 3 def products @products end |
#total_pages ⇒ Object (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
#filename ⇒ Object
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 |