File Coverage

blib/lib/RapidApp/Spreadsheet/ExcelTableWriter/ColDef.pm
Criterion Covered Total %
statement 9 18 50.0
branch 0 6 0.0
condition n/a
subroutine 3 6 50.0
pod 0 1 0.0
total 12 31 38.7


line stmt bran cond sub pod time code
1             package RapidApp::Spreadsheet::ExcelTableWriter::ColDef;
2              
3 4     4   28 use strict;
  4         11  
  4         113  
4 4     4   18 use warnings;
  4         10  
  4         91  
5 4     4   20 use Moose;
  4         10  
  4         34  
6              
7             has 'name' => ( is => 'rw', lazy_build => 1 );
8             has 'label' => ( is => 'rw', lazy_build => 1 );
9             has 'isString' => ( is => 'rw', required => 1, default => 1 );
10             has 'format' => ( is => 'rw' );
11              
12             # widths are given in Excel width units
13             # one unit is the width of the average character in Arial 10pt
14             has 'width' => ( is => 'rw', required => 1, default => 'auto' );
15             has 'widest' => ( is => 'rw', default => 2 );
16              
17             sub _build_label {
18 0     0     my $self= shift;
19 0 0         $self->has_name or die "Either field or label must be specified";
20 0           return $self->name;
21             }
22              
23             sub _build_name {
24 0     0     my $self= shift;
25 0 0         $self->has_label or die "Either field or label must be specified";
26 0           return $self->label;
27             }
28              
29             sub updateWidest {
30 0     0 0   my $self= shift;
31 0           my $newWidth= shift;
32 0 0         $self->widest >= $newWidth or $self->widest($newWidth);
33             }
34              
35             1;