Class: Camper::PaginationData
- Includes:
- Logging
- Defined in:
- lib/camper/pagination_data.rb
Constant Summary collapse
- HEADER_LINK =
'Link'
- HEADER_TOTAL_COUNT =
'X-Total-Count'
- DELIM_LINKS =
','
- LINK_REGEX =
/<([^>]+)>; rel="([^"]+)"/.freeze
- METAS =
%w[next].freeze
Instance Attribute Summary collapse
-
#total_count ⇒ Object
Returns the value of attribute total_count.
Attributes included from Logging
Instance Method Summary collapse
-
#initialize(headers) ⇒ PaginationData
constructor
A new instance of PaginationData.
- #inspect ⇒ Object
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_count ⇒ Object
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
#inspect ⇒ Object
25 26 27 |
# File 'lib/camper/pagination_data.rb', line 25 def inspect "Next URL: #{@next}; Total Count: #{@total_count}" end |