line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Table::Simple::Column; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
43
|
use Moose; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
46
|
|
4
|
6
|
|
|
6
|
|
41294
|
use Moose::Util::TypeConstraints; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
48
|
|
5
|
6
|
|
|
6
|
|
13114
|
use namespace::autoclean; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
56
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Table::Simple::Column - A collection of data points organized into rows |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Typically you want to use this module in conjunction with L<Table::Simple> |
14
|
|
|
|
|
|
|
table object. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head2 ATTRIBUTES |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=over 4 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=item width |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This attribute stores the length of the widest element in the column including |
23
|
|
|
|
|
|
|
the name of the column. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=back |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has 'width' => ( |
30
|
|
|
|
|
|
|
is => 'rw', |
31
|
|
|
|
|
|
|
isa => 'Int', |
32
|
|
|
|
|
|
|
lazy_build => 1, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=over 4 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item name |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This is a required attribute which stores the name of the column. It should |
40
|
|
|
|
|
|
|
match the name of an attribute on a class to be scanned by the software. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=back |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has 'name' => ( |
47
|
|
|
|
|
|
|
is => 'ro', |
48
|
|
|
|
|
|
|
isa => 'Str', |
49
|
|
|
|
|
|
|
required => 1, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=over 4 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item output_format |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This attribute controls the output layout. This should match a method in |
57
|
|
|
|
|
|
|
L<Table::Simple::Output> or a subclass of that. The following methods |
58
|
|
|
|
|
|
|
are available in the standard L<Table::Simple::Output> class: |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=over 4 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item left_justify |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item center |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item right_justify |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=back |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=back |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
has 'output_format' => ( |
75
|
|
|
|
|
|
|
is => 'rw', |
76
|
|
|
|
|
|
|
isa => 'Str', |
77
|
|
|
|
|
|
|
default => 'left_justify', |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=over 4 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item rows |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This attribute is a collection of data elements corresponding to the |
85
|
|
|
|
|
|
|
attribute values matching the column name. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This attribute has a number of methods which permit you to manipulate |
88
|
|
|
|
|
|
|
the collection. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
has 'rows' => ( |
95
|
|
|
|
|
|
|
is => 'ro', |
96
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
97
|
|
|
|
|
|
|
traits => [ 'Array' ], |
98
|
|
|
|
|
|
|
default => sub { [] }, |
99
|
|
|
|
|
|
|
handles => { |
100
|
|
|
|
|
|
|
'add_row' => 'push', |
101
|
|
|
|
|
|
|
'get_rows' => 'elements', |
102
|
|
|
|
|
|
|
'get_row' => 'get', |
103
|
|
|
|
|
|
|
}, |
104
|
|
|
|
|
|
|
lazy => 1, |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
after 'add_row' => sub { |
108
|
|
|
|
|
|
|
my $self = shift; |
109
|
|
|
|
|
|
|
my $new = shift; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
if ( length($new) > $self->width ) { |
112
|
|
|
|
|
|
|
$self->width( length($new) ); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
}; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 METHODS |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=over 4 |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item add_row( $string ) |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This method adds a new row value (string scalar) to the collection. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item get_rows |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This method returns all values stored in the collection. It preserves the |
127
|
|
|
|
|
|
|
order in which values were added to the collection. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item get_row |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This method returns a specific value stored in collection. It takes the |
132
|
|
|
|
|
|
|
desired value's index as input and returns the value as output. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=back |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub _build_width { |
139
|
8
|
|
|
8
|
|
18
|
my $self = shift; |
140
|
|
|
|
|
|
|
|
141
|
8
|
50
|
|
|
|
233
|
return $self->name ? length($self->name) : 0; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 LICENSE |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Copyright (C) 2010 Mark Allen |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
149
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
150
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Mark Allen <mrallen1@yahoo.com> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 SEE ALSO |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
L<Moose>, L<Table::Simple>, L<Table::Simple::Output> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
165
|
|
|
|
|
|
|
1; |