Class: EPlat::Paginated::WoocommercePagination

Inherits:
Object
  • Object
show all
Defined in:
lib/e_plat/paginated/woocommerce_pagination.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

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

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