Catmandu::Paged(3pm)

Catmandu::Paged3pm

Base class for packages that need paging result sets

Usage

    # Create a package that needs page calculation
    package MyPackage;
    use Moo;
    with 'Catmandu::Paged';
    sub start {
        12; # Starting result
    }
    sub limit  {
        10; # Number of results per page
    }
    sub total {
        131237128371; # Total number of results;
    }
    package main;
    my $x = MyPackage->new;
    printf "Start page: %s\n" , $x->first_page;
    printf "Last page: %s\n" , $x->last_page;
    printf "Current page: %s\n" , $x->page;
    printf "Next page: %s\n" , $x->next_page;

Overview

Packages that use Catmandu::Paged as base class and implement the methods "start", "limit" and "total" get for free methods that can be used to do page calculation.

Overwrite methods

start()

Returns the index of the first item in a result page.

limit()

Returns the number of results in a page.

total()

Returns the total number of search results.

Instance methods

first_page

Returns the index the first page in a search result containing 0 or more pages.

last_page

Returns the index of the last page in a search result containing 0 or more pages.

page_size

Returns the number items on the current page.

page

Returns the current page index.

previous_page

Returns the previous page index.

next_page

Returns the next page index.

first_on_page

Returns the result index of the first result on the page.

page_ranges
pages_in_spread

Returns the previous pages and next pages, depending on the current position in the result set.

Releases

6 releases since Debian 8 (Jessie); the text changed 5 times.

  1. 8
  2. 9
  3. 10
  4. 11
  5. 12
  6. 13

From libcatmandu-perl 1.2024-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.