logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Text::SimpleTable::AutoWidth - Text::SimpleTable::AutoWidth - Simple eyecandy ASCII tables with

Author

       Oleg Kostyuk <cub.uanic@gmail.com>

Description

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

Git Repository

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

Methods

new(@attrs)
       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 hyphen (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 hyphen (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.

   row(@texts)
       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()
       Draw table. Really, just calculate column width, and then call Text::SimpleTable->draw().

Name

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

See Also

       Text::SimpleTable, Moo, Catalyst

Synopsis

           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         |
           '-----------------+--------------'

Version

       version 0.09

See Also