Class: Camper::PaginationData

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/camper/pagination_data.rb

Constant Summary collapse

'Link'
HEADER_TOTAL_COUNT =
'X-Total-Count'
','
/<([^>]+)>; rel="([^"]+)"/.freeze
METAS =
%w[next].freeze

Instance Attribute Summary collapse

Attributes included from Logging

#logger

Instance Method Summary collapse

Constructor Details

#initialize(headers) ⇒ PaginationData

Returns a new instance of PaginationData.



17
18
19
20
21
22
23
# File 'lib/camper/pagination_data.rb', line 17

def initialize(headers)
  link_header = headers[HEADER_LINK]

  @total_count = headers[HEADER_TOTAL_COUNT].to_i

  extract_links(link_header) if link_header && link_header =~ /(next)/
end

Instance Attribute Details

#total_countObject

Returns the value of attribute total_count.



15
16
17
# File 'lib/camper/pagination_data.rb', line 15

def total_count
  @total_count
end

Instance Method Details

#inspectObject



25
26
27
# File 'lib/camper/pagination_data.rb', line 25

def inspect
  "Next URL: #{@next}; Total Count: #{@total_count}"
end