Class: EPlat::Paginated::WoocommercePagination
- Inherits:
-
Object
- Object
- EPlat::Paginated::WoocommercePagination
- Defined in:
- lib/e_plat/paginated/woocommerce_pagination.rb
Instance Attribute Summary collapse
-
#next_link ⇒ Object
readonly
Returns the value of attribute next_link.
-
#previous_link ⇒ Object
readonly
Returns the value of attribute previous_link.
Instance Method Summary collapse
-
#initialize(headers) ⇒ WoocommercePagination
constructor
A new instance of WoocommercePagination.
Constructor Details
#initialize(headers) ⇒ WoocommercePagination
Returns a new instance of WoocommercePagination.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/e_plat/paginated/woocommerce_pagination.rb', line 6 def initialize(headers) return unless headers # WooCommerce uses X-WP-Total and X-WP-TotalPages headers for pagination info # And link headers for next/prev links @total = headers["X-WP-Total"].to_i if headers["X-WP-Total"] @total_pages = headers["X-WP-TotalPages"].to_i if headers["X-WP-TotalPages"] # Parse link headers if headers["Link"] parse_link_headers(headers["Link"]) end end |
Instance Attribute Details
#next_link ⇒ Object (readonly)
Returns the value of attribute next_link.
4 5 6 |
# File 'lib/e_plat/paginated/woocommerce_pagination.rb', line 4 def next_link @next_link end |
#previous_link ⇒ Object (readonly)
Returns the value of attribute previous_link.
4 5 6 |
# File 'lib/e_plat/paginated/woocommerce_pagination.rb', line 4 def previous_link @previous_link end |