File Coverage

blib/lib/PDF/TableX/Column.pm
Criterion Covered Total %
statement 33 33 100.0
branch 4 4 100.0
condition n/a
subroutine 9 9 100.0
pod 3 3 100.0
total 49 49 100.0


line stmt bran cond sub pod time code
1             package PDF::TableX::Column;
2              
3 7     7   64 use Moose;
  7         15  
  7         64  
4 7     7   49595 use MooseX::Types;
  7         17  
  7         71  
5              
6 7     7   30888 use PDF::TableX::Types qw/StyleDefinition/;
  7         16  
  7         69  
7 7     7   7111 use PDF::TableX::Cell;
  7         20  
  7         57  
8              
9             with 'PDF::TableX::Stylable';
10              
11             has rows => (is => 'ro', isa => 'Int', default => 0);
12             has width => (is => 'rw', isa => 'Num');
13              
14 7     7   2833 use overload '@{}' => sub { return $_[0]->{_children} }, fallback => 1;
  7     1   17  
  7         364  
  1         6  
15              
16             around 'width' => sub {
17             my $orig = shift;
18             my $self = shift;
19             return $self->$orig() unless @_;
20             for (@{ $self->{_children} }) { $_->width(@_) };
21             $self->$orig(@_);
22             return $self;
23             };
24              
25             sub add_cell {
26 146     146 1 265 my ($self, $cell) = @_;
27 146         185 push @{$self->{_children}}, $cell;
  146         415  
28             }
29              
30             sub get_min_width {
31 21     21 1 68 my ($self) = @_;
32 21         53 my $width = 0;
33 21         52 for my $cell_min_width ( map {$_->min_width} @{$self->{_children}} ) {
  146         4344  
  21         128  
34 146 100       346 $width = $cell_min_width if ($cell_min_width > $width);
35             }
36 21         144 return $width;
37             }
38              
39             sub get_reg_width {
40 21     21 1 76 my ($self) = @_;
41 21         49 my $width = 0;
42 21         54 for my $cell_reg_width ( map {$_->reg_width} @{$self->{_children}} ) {
  146         4190  
  21         147  
43 146 100       336 $width = $cell_reg_width if ($cell_reg_width > $width);
44             }
45 21         143 return $width;
46             }
47              
48             1;
49              
50             =head1 NAME
51              
52             PDF::TableX::Column
53              
54             =head1 VERSION
55              
56             Version 0.01
57              
58             =head1 SYNOPSIS
59              
60             =head1 METHODS
61              
62             =head2 add_cell
63              
64             TODO
65              
66             =head2 get_min_width
67              
68             TODO
69              
70             =head2 get_reg_width
71              
72             TODO
73              
74             =head1 AUTHOR
75              
76             Grzegorz Papkala, C<< <grzegorzpapkala at gmail.com> >>
77              
78             =head1 BUGS
79              
80             Please report any bugs or feature requests at: L<https://github.com/grzegorzpapkala/PDF-TableX/issues>
81              
82             =head1 SUPPORT
83              
84             PDF::TableX is hosted on GitHub L<https://github.com/grzegorzpapkala/PDF-TableX>
85              
86             =head1 ACKNOWLEDGEMENTS
87              
88             =head1 COPYRIGHT & LICENSE
89              
90             Copyright 2013 Grzegorz Papkala, all rights reserved.
91              
92             This program is free software; you can redistribute it and/or modify it
93             under the same terms as Perl itself.
94              
95             =cut