Text::...oWidth(3pm)

πŸ“¦
version 0.09 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Text::SimpleTable::AutoWidth β€” the manual, but make it cute πŸ’–

okay so bestie, welcome to the Text::...oWidth(3pm) page β€” that's the shorthand name the manual wears when it's chilling in the perl docs, and the whole thing is called Text::SimpleTable::AutoWidth. And yes, the full NAME is literally doubled up like that, we're keeping it, it's giving maximalist πŸ’…


✨ NAME ✨

Text::SimpleTable::AutoWidth</purl> β€” Text::SimpleTable::AutoWidth - Simple eyecandy ASCII tables with auto-width selection ✨


πŸŽ€ VERSION πŸŽ€

version 0.09


πŸ¦‹ SYNOPSIS πŸ¦‹

okay so here's the whole vibe, copy-paste ready:

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

look at those little ASCII tables, they're so tidy, I'm obsessed πŸ˜­πŸ’–


🌸 DESCRIPTION 🌸

Simple eyecandy ASCII tables with auto-selection columns width, as seen in Catalyst. That's it, that's the whole pitch β€” you feed it rows, it figures out the widths itself, and you get a pretty table. Periodt. πŸ‘‘


πŸ’… 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 bestie, 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.
same warning, no cap, 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. both at once is valid, it's just a lil compromise ✨

  • 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 β€” chaining goes hard:

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(). the actual drawing is outsourced, she's just doing the math πŸ’…


🧚 GIT REPOSITORY 🧚

go clone it, bestie:

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

⭐ SEE ALSO ⭐

Text::SimpleTable, Moo, Catalyst β€” the friend group 🫢


πŸ‘‘ AUTHOR πŸ‘‘

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.


πŸ‘‘ AUTHOR (again, bestie) πŸ‘‘

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.


and that's the whole page, mwah πŸ’‹

cute sign-off time: this was perl v5.34.0, dated 2022-06-27, and the manual name on the tin is Text::...oWidth(3pm). slay, go make some eyecandy tables πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from