Data-PaginatedTable

 view release on metacpan or  search on metacpan

META.yml  view on Meta::CPAN

license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: Data-PaginatedTable
provides:
  Data::PaginatedTable:
    file: lib/Data/PaginatedTable.pm
    version: v1.0.0
requires:
  Modern::Perl: '0'
  Moops: '0'
  POSIX: '0'
  Text::Table: '0'
  Types::XSD::Lite: '0'
  XML::Simple: '0'
  XML::Simple::Sugar: '0'
  constant: '0'
  overload: '0'
  perl: v5.18.2
resources:

Makefile.PL  view on Meta::CPAN

  "AUTHOR" => "Chris Tijerina",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "Data-PaginatedTable",
  "EXE_FILES" => [],
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.018002",
  "NAME" => "Data::PaginatedTable",
  "PREREQ_PM" => {
    "Modern::Perl" => 0,
    "Moops" => 0,
    "POSIX" => 0,
    "Text::Table" => 0,
    "Types::XSD::Lite" => 0,
    "XML::Simple" => 0,
    "XML::Simple::Sugar" => 0,
    "constant" => 0,
    "overload" => 0
  },
  "TEST_REQUIRES" => {

Makefile.PL  view on Meta::CPAN

  },
  "VERSION" => "1.0.0",
  "test" => {
    "TESTS" => "t/*.t"
  }
);


my %FallbackPrereqs = (
  "ExtUtils::MakeMaker" => 0,
  "Modern::Perl" => 0,
  "Moops" => 0,
  "POSIX" => 0,
  "Test::More" => 0,
  "Text::Table" => 0,
  "Types::XSD::Lite" => 0,
  "XML::Simple" => 0,
  "XML::Simple::Sugar" => 0,
  "constant" => 0,
  "overload" => 0
);

README  view on Meta::CPAN

SYNOPSIS

        use Modern::Perl;
        use Data::PaginatedTable;
        use Data::Printer;
        
        my @series = 'aaa' .. 'zzz';
        
        my $pt = Data::PaginatedTable->new(
            {
                data           => \@series,
                string_mode    => 'preformatted',
                fill_direction => 'vertical',

README  view on Meta::CPAN

 columns, columns ( PositiveInteger default => 3 )

    Gets or sets the number of columns per row.

 fill_direction, fill_direction ( Enum[ 'vertical', 'horizontal' ] default
 => 'horizontal' )

    Gets or sets the order in which data elements will be used to fill the
    two-dimensional array of each page.

        use Modern::Perl;
        use Data::PaginatedTable;
        
        my @series = 1 .. 9;
        
        my $pt = Data::PaginatedTable->new(
            {
                data           => \@series,
                rows           => 3,
                columns        => 3,
                fill_direction => 'vertical', # default horizontal

README  view on Meta::CPAN

 as_string

    This is a wrapper around the as_* string_mode methods. This method is
    called implicitly when the instance is in string context.

 as_html

    The html string_mode stringifies the current page as a plain html
    table. All page elements are placed in string context (see overload).

        use Modern::Perl;
        use Data::PaginatedTable;
        
        my @series = 1 .. 12;
        
        my $pt = Data::PaginatedTable->new(
            {
                data        => \@series,
                string_mode => 'html'
            }
        );

README  view on Meta::CPAN

        #     <td>11</td>
        #     <td>12</td>
        #   </tr>
        # </table>

 as_preformatted

    The preformatted string_mode uses Text::Table to format the current
    page. All page elements are placed in string context (see overload).

        use Modern::Perl;
        use Data::PaginatedTable;
        
        my @series = 1 .. 12;
        
        my $pt = Data::PaginatedTable->new(
            {
                data        => \@series,
                string_mode => 'preformatted'
            }
        );

README.mkdn  view on Meta::CPAN

# NAME

Data::PaginatedTable - Paginate lists as two-dimensional arrays and stringify

# VERSION

version 1.0.0

# SYNOPSIS

    use Modern::Perl;
    use Data::PaginatedTable;
    use Data::Printer;
    
    my @series = 'aaa' .. 'zzz';
    
    my $pt = Data::PaginatedTable->new(
        {
            data           => \@series,
            string_mode    => 'preformatted',
            fill_direction => 'vertical',

README.mkdn  view on Meta::CPAN

Gets or sets the number of rows per `page`.

## columns, columns ( PositiveInteger default => 3 )

Gets or sets the number of columns per `row`.

## fill\_direction, fill\_direction ( Enum\[ 'vertical', 'horizontal' \] default => 'horizontal' )

Gets or sets the order in which `data` elements will be used to fill the two-dimensional array of each `page`.

    use Modern::Perl;
    use Data::PaginatedTable;
    
    my @series = 1 .. 9;
    
    my $pt = Data::PaginatedTable->new(
        {
            data           => \@series,
            rows           => 3,
            columns        => 3,
            fill_direction => 'vertical', # default horizontal

README.mkdn  view on Meta::CPAN

# STRING MODES

## as\_string

This is a wrapper around the as\_\* `string_mode` methods.  This method is called implicitly when the instance is in string context.

## as\_html

The html `string_mode` stringifies the `current` `page` as a plain html table.  All `page` elements are placed in string context (see [overload](https://metacpan.org/pod/overload)).

    use Modern::Perl;
    use Data::PaginatedTable;
    
    my @series = 1 .. 12;
    
    my $pt = Data::PaginatedTable->new(
        {
            data        => \@series,
            string_mode => 'html'
        }
    );

README.mkdn  view on Meta::CPAN

    #     <td>10</td>
    #     <td>11</td>
    #     <td>12</td>
    #   </tr>
    # </table>

## as\_preformatted

The preformatted `string_mode` uses [Text::Table](https://metacpan.org/pod/Text::Table) to format the `current` `page`. All `page` elements are placed in string context (see [overload](https://metacpan.org/pod/overload)).

    use Modern::Perl;
    use Data::PaginatedTable;
    
    my @series = 1 .. 12;
    
    my $pt = Data::PaginatedTable->new(
        {
            data        => \@series,
            string_mode => 'preformatted'
        }
    );

lib/Data/PaginatedTable.pm  view on Meta::CPAN

use 5.18.2;
use Modern::Perl;
use Moops;

class Data::PaginatedTable 1.0.0 {
    use Types::XSD::Lite qw( PositiveInteger );
    use Text::Table;
    use XML::Simple;
    use XML::Simple::Sugar;
    use POSIX qw(ceil);
    use overload '""'         => 'as_string';
    use overload '@{}'        => 'pages';

lib/Data/PaginatedTable.pm  view on Meta::CPAN

=head1 NAME

Data::PaginatedTable - Paginate lists as two-dimensional arrays and stringify

=head1 VERSION

version 1.0.0

=head1 SYNOPSIS

    use Modern::Perl;
    use Data::PaginatedTable;
    use Data::Printer;
    
    my @series = 'aaa' .. 'zzz';
    
    my $pt = Data::PaginatedTable->new(
        {
            data           => \@series,
            string_mode    => 'preformatted',
            fill_direction => 'vertical',

lib/Data/PaginatedTable.pm  view on Meta::CPAN

Gets or sets the number of rows per C<page>.

=head2 columns, columns ( PositiveInteger default => 3 )

Gets or sets the number of columns per C<row>.

=head2 fill_direction, fill_direction ( Enum[ 'vertical', 'horizontal' ] default => 'horizontal' )

Gets or sets the order in which C<data> elements will be used to fill the two-dimensional array of each C<page>.

    use Modern::Perl;
    use Data::PaginatedTable;
    
    my @series = 1 .. 9;
    
    my $pt = Data::PaginatedTable->new(
        {
            data           => \@series,
            rows           => 3,
            columns        => 3,
            fill_direction => 'vertical', # default horizontal

lib/Data/PaginatedTable.pm  view on Meta::CPAN

=head1 STRING MODES

=head2 as_string

This is a wrapper around the as_* C<string_mode> methods.  This method is called implicitly when the instance is in string context.

=head2 as_html

The html C<string_mode> stringifies the C<current> C<page> as a plain html table.  All C<page> elements are placed in string context (see L<overload>).

    use Modern::Perl;
    use Data::PaginatedTable;
    
    my @series = 1 .. 12;
    
    my $pt = Data::PaginatedTable->new(
        {
            data        => \@series,
            string_mode => 'html'
        }
    );

lib/Data/PaginatedTable.pm  view on Meta::CPAN

    #     <td>10</td>
    #     <td>11</td>
    #     <td>12</td>
    #   </tr>
    # </table>

=head2 as_preformatted

The preformatted C<string_mode> uses L<Text::Table> to format the C<current> C<page>. All C<page> elements are placed in string context (see L<overload>).

    use Modern::Perl;
    use Data::PaginatedTable;
    
    my @series = 1 .. 12;
    
    my $pt = Data::PaginatedTable->new(
        {
            data        => \@series,
            string_mode => 'preformatted'
        }
    );

t/data-paginatedtable.t  view on Meta::CPAN

use Modern::Perl;
use Test::More;
use Data::PaginatedTable;

my @series = 1 .. 12;
my $dt = Data::PaginatedTable->new( { data => \@series } );

ok $dt->page_count == 1, '1 page';

$dt->rows(2);
$dt->columns(3);



( run in 0.512 second using v1.01-cache-2.11-cpan-a5abf4f5562 )