| Data-Timeline documentation | Contained in the Data-Timeline distribution. |
Data::Timeline::Formatter::SimpleTable - Print time line entry types side-by-side in a text table
version 1.100860
Data::Timeline::Formatter::SimpleTable->new(
columns => [ [ 40, 'iscrobbler' ], [ 40, 'svk' ] ],
)->format($timeline);
This class is a time line formatter. It takes a time line containing entries
of one or more entry types and a column definition. The column definition says
for each column how wide it should be and which type of entries it should
contain. The formatter's format() method will then print a simple text
table containing the requested columns, with a column for the timestamp at the
beginning.
The column definition is a list of [ $width, $type ] pairs. So for the
example in the synopsis, the first column would contain the timestamp, the
second column would be 40 characters wide and contain iscrobbler entries,
produced by Data::Timeline::IScrobbler, and the third column would also
be 40 characters wide and contain svk entries, produced by
Data::Timeline::SVK.
FIXME
See perlmodinstall for information and options on installing Perl modules.
No bugs have been reported.
Please report any bugs or feature requests through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Timeline.
The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see http://search.cpan.org/dist/Data-Timeline/.
The development version lives at http://github.com/hanekomu/Data-Timeline/. Instead of sending patches, please fork this project using the standard git and github infrastructure.
Marcel Gruenauer <marcel@cpan.org>
This software is copyright (c) 2007 by Marcel Gruenauer.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
| Data-Timeline documentation | Contained in the Data-Timeline distribution. |
use 5.008; use strict; use warnings; package Data::Timeline::Formatter::SimpleTable; our $VERSION = '1.100860'; # ABSTRACT: Print time line entry types side-by-side in a text table use Text::SimpleTable; use parent qw(Data::Timeline::Formatter); __PACKAGE__->mk_array_accessors(qw(columns)); sub format { my ($self, $timeline) = @_; my $table = Text::SimpleTable->new([ 20, 'timestamp' ], $self->columns,); my @col_types = map { $_->[1] } $self->columns; for my $entry ($timeline->entries) { my @row = (sprintf "%s" => $entry->timestamp); for my $col_type (@col_types) { if ($entry->type eq $col_type) { push @row => $entry->description; } else { push @row => ''; } } $table->row(@row); } print $table->draw; } 1; __END__