GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Text::SimpleTable::AutoWidth(3) User Contributed Perl Documentation Text::SimpleTable::AutoWidth(3)

Text::SimpleTable::AutoWidth - Text::SimpleTable::AutoWidth - Simple eyecandy ASCII tables with auto-width selection

version 0.09

    use Text::SimpleTable::AutoWidth;

    my $t1 = Text::SimpleTable::AutoWidth->new();
    $t1->row( 'foobarbaz', 'yadayadayada' );
    print $t1->draw;

    .-----------+--------------.
    | foobarbaz | yadayadayada |
    '-----------+--------------'


    my $t2 = Text::SimpleTable::AutoWidth->new();
    $t2->captions( 'Foo', 'Bar' );
    $t2->row( 'foobarbaz', 'yadayadayada' );
    $t2->row( 'barbarbarbarbar', 'yada' );
    print $t2->draw;

    .-----------------+--------------.
    | Foo             | Bar          |
    +-----------------+--------------+
    | foobarbaz       | yadayadayada |
    | barbarbarbarbar | yada         |
    '-----------------+--------------'

Simple eyecandy ASCII tables with auto-selection columns width, as seen in Catalyst.

Inherited constructor from Moo. You can set following attributes:

fixed_width

Set fixed width for resulting table. By default it's 0, that's mean "don't fix width", so width of result table will depend on input data.

Be warned, that fixed_width will include not only width of your data, but also all surronding characters, like spaces across values, table drawings (like '|') and hypen (if wrapping is needed).

max_width

Set maximum width for resulting table. By default it's 0, that's mean "use default value". Default value is stored in $Text::SimpleTable::AutoWidth::WIDTH_LIMIT, and can be changed at any moment. Default value for WIDTH_LIMIT is 200.

Be warned, that max_width will include not only width of your data, but also all surronding characters, like spaces across values, table drawings (like '|') and hypen (if wrapping is needed).

NB: if you set fixed_width and max_width at same time, then you'll get table with fixed width, but not wider than max_width characters.

captions

ArrayRef[Str] for captions in resulting table.

rows

ArrayRef[ArrayRef[Str]] for values in each row. You can use next method to add individual rows into table.

Add new row to table. Return $self, so you can write something like this:

    print Text::SimpleTable::AutoWidth
        ->new( max_width => 55, captions => [qw/ Name Age /] )
        ->row( 'Mother', 59 )
        ->row( 'Dad', 58 )
        ->row( 'me', 32 )
        ->draw();

Draw table. Really, just calculate column width, and then call Text::SimpleTable->draw().

git clone git://github.com/cub-uanic/Text-SimpleTable-AutoWidth.git

Text::SimpleTable, Moo, Catalyst

Oleg Kostyuk, "<cub#cpan.org>"

Copyright by Oleg Kostyuk.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

Oleg Kostyuk <cub.uanic@gmail.com>

This software is copyright (c) 2015 by Oleg Kostyuk.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2015-01-29 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.