NAME

Text::UnicodeBox::Table - High level interface providing easy table drawing

SYNOPSIS

my $table = Text::UnicodeBox::Table->new();

$table->add_header('id', 'name');
$table->add_row('1', 'George Washington');
$table->add_row('2', 'Thomas Jefferson');
print $table->render();

# Prints:
# ┌────┬───────────────────┐
# │ id │ name              │
# ├────┼───────────────────┤
# │  1 │ George Washington │
# │  2 │ Thomas Jefferson  │
# └────┴───────────────────┘

DESCRIPTION

This module provides an easy high level interface over Text::UnicodeBox.

METHODS

new

style
my $table = Text::UnicodeBox::Table->new( style => 'horizontal_double ');

You may specify a certain style for the table to be drawn. This may be overridden on a per row basis.

light

All lines are light.

heavy

All lines are heavy.

double

All lines are double.

horizontal_double

All horizontal lines are double, where vertical lines are single.

heavy_header

The lines drawing the header are heavy, all others are light.

add_header ( [\%opt,] @parts )

$table->add_header({ bottom => 'heavy' }, 'Name', 'Age', 'Address');

Same as add_row but sets the option ('header' => 1)

Draws one line of output with a border on the top and bottom.

add_row ( [\%opt,] @parts )

If the first argument to this method is a hashref, it is interpreted as an options hash. This hash takes the following parameters:

style (default: 'light')

What style will be used for all box characters involved in this line of output. Options are: 'light', 'double', 'heavy'

alignment
 alignment => [ 'right', 'left', 'right' ]

Pass a list of 'right' and 'left', corresponding with the number of columns of output. This will control the alignment of this row, and if passed to add_header, all following rows as well. By default, values looking like a number are aligned to the right, with all other values aligned to the left.

header_alignment

The header will always be aligned to the left unless you pass this array ref to specify custom alignment.

top
bottom

If set, draw a line above or below the current line.

Same as passing top and bottom to the given style (or the default style style)

output_width

Returns the width of the table if it were rendered right now without additional rows added.

COPYRIGHT

Copyright (c) 2012 Eric Waters and Shutterstock Images (http://shutterstock.com). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

AUTHOR

Eric Waters <ewaters@gmail.com>