| 1 | 1 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | package Data::Timeline::Formatter::SimpleTable; | ||||||||||
| 6 | 1 | our $VERSION = '1.100860'; | |||||||||
| 7 | # ABSTRACT: Print time line entry types side-by-side in a text table | ||||||||||
| 8 | 1 | ▶ | use Text::SimpleTable; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use parent qw(Data::Timeline::Formatter); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | __PACKAGE__->mk_array_accessors(qw(columns)); | |||||||||
| 11 | |||||||||||
| 12 | 0 | ▶ | sub format { | ||||||||
|
Subroutine
format: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 13 | 0 | my ($self, $timeline) = @_; | |||||||||
| 14 | 0 | my $table = Text::SimpleTable->new([ 20, 'timestamp' ], $self->columns,); | |||||||||
| 15 | 0 | my @col_types = map { $_->[1] } $self->columns; | |||||||||
| 16 | 0 | for my $entry ($timeline->entries) { | |||||||||
| 17 | 0 | my @row = (sprintf "%s" => $entry->timestamp); | |||||||||
| 18 | 0 | for my $col_type (@col_types) { | |||||||||
| 19 | 0 | ▶ | if ($entry->type eq $col_type) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 0 | push @row => $entry->description; | |||||||||
| 21 | } else { | ||||||||||
| 22 | 0 | push @row => ''; | |||||||||
| 23 | } | ||||||||||
| 24 | } | ||||||||||
| 25 | 0 | $table->row(@row); | |||||||||
| 26 | } | ||||||||||
| 27 | 0 | print $table->draw; | |||||||||
| 28 | } | ||||||||||
| 29 | 1 | 1; | |||||||||
| 30 | |||||||||||
| 31 | |||||||||||
| 32 | __END__ | ||||||||||