Catmandu::Paged(3pm)

πŸ“¦
version 1.2025 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– Catmandu::Paged πŸ’–

okay bestie, so this is Catmandu::Paged β€” it's a base class for packages that need to do paging on result sets. it's giving "i do the math so you don't have to" energy and honestly? obsessed. ✨


✨ SYNOPSIS ✨

    # 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;

🌸 DESCRIPTION 🌸

so here's the tea, bestie πŸ«– β€” any package that uses Catmandu::Paged as its base class, and implements the methods start, limit and total, gets a whole lil squad of page-calculation methods for free. no cap, you literally just write three subs and the rest shows up like a gift. 🎁


πŸ’… OVERWRITE METHODS πŸ’…

these are the three you gotta bring yourself, bestie. they're the main character methods, fr fr.

  • 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 πŸŽ€

these ones come free with the class, and they ate. πŸ’…

  • first_page β€” returns the index of 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 of 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 where you're currently at in the result set. πŸ¦‹

🫢 SEE ALSO 🫢

  • Catmandu::Hits β€” go say hi, bestie πŸ’–

okay and that's the whole vibe check βœ… β€” this page was riding with perl v5.40.1, dated 2026-01-24, and it's part of the User Contributed Perl Documentation collection. slay, you read the whole thing, i'm so proud of you πŸ₯ΉπŸ’œ periodt.

πŸ“¦ where this page comes from