line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TableDataRole::Source::AOA; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
925
|
use 5.010001; |
|
2
|
|
|
|
|
7
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
41
|
|
5
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
11
|
use Role::Tiny; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
10
|
|
|
|
|
|
|
our $DATE = '2023-06-14'; # DATE |
11
|
|
|
|
|
|
|
our $DIST = 'TableDataRoles-Standard'; # DIST |
12
|
|
|
|
|
|
|
our $VERSION = '0.016'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
with 'TableDataRole::Spec::Basic'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
2
|
|
|
2
|
0
|
123
|
my ($class, %args) = @_; |
18
|
|
|
|
|
|
|
|
19
|
2
|
50
|
|
|
|
11
|
my $column_names = delete $args{column_names} or die "Please specify 'column_names' argument"; |
20
|
2
|
50
|
|
|
|
6
|
my $aoa = delete $args{aoa} or die "Please specify 'aoa' argument"; |
21
|
2
|
50
|
|
|
|
8
|
die "Unknown argument(s): ". join(", ", sort keys %args) |
22
|
|
|
|
|
|
|
if keys %args; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
bless { |
25
|
|
|
|
|
|
|
aoa => $aoa, |
26
|
|
|
|
|
|
|
pos => 0, |
27
|
|
|
|
|
|
|
column_names => $column_names, |
28
|
2
|
|
|
|
|
6
|
column_idxs => {map {$column_names->[$_] => $_} 0..$#{$column_names}}, |
|
5
|
|
|
|
|
28
|
|
|
2
|
|
|
|
|
8
|
|
29
|
|
|
|
|
|
|
}, $class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub get_column_count { |
33
|
2
|
|
|
2
|
0
|
15
|
my $self = shift; |
34
|
2
|
|
|
|
|
9
|
scalar @{ $self->{column_names} }; |
|
2
|
|
|
|
|
15
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub get_column_names { |
38
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
39
|
2
|
50
|
|
|
|
8
|
wantarray ? @{ $self->{column_names} } : $self->{column_names}; |
|
2
|
|
|
|
|
14
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub has_next_item { |
43
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
44
|
0
|
|
|
|
|
0
|
$self->{pos} < @{$self->{aoa}}; |
|
0
|
|
|
|
|
0
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_next_item { |
48
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
49
|
2
|
|
|
|
|
14
|
my $aoa = $self->{aoa}; |
50
|
2
|
50
|
|
|
|
6
|
die "StopIteration" unless $self->{pos} < @{$aoa}; |
|
2
|
|
|
|
|
9
|
|
51
|
2
|
|
|
|
|
12
|
$aoa->[ $self->{pos}++ ]; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub get_next_row_hashref { |
55
|
4
|
|
|
4
|
0
|
8
|
my $self = shift; |
56
|
4
|
|
|
|
|
9
|
my $aoa = $self->{aoa}; |
57
|
4
|
50
|
|
|
|
15
|
die "StopIteration" unless $self->{pos} < @{$aoa}; |
|
4
|
|
|
|
|
16
|
|
58
|
4
|
|
|
|
|
14
|
my $row_aryref = $aoa->[ $self->{pos}++ ]; |
59
|
4
|
|
|
|
|
14
|
+{ map { $self->{column_names}[$_] => $row_aryref->[$_] } 0..$#{$self->{column_names}} }; |
|
10
|
|
|
|
|
56
|
|
|
4
|
|
|
|
|
15
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub get_row_count { |
63
|
2
|
|
|
2
|
0
|
13
|
my $self = shift; |
64
|
2
|
|
|
|
|
4
|
scalar(@{ $self->{aoa} }); |
|
2
|
|
|
|
|
9
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub reset_iterator { |
68
|
4
|
|
|
4
|
0
|
9
|
my $self = shift; |
69
|
4
|
|
|
|
|
9
|
$self->{pos} = 0; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub get_iterator_pos { |
73
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
74
|
0
|
|
|
|
|
|
$self->{pos}; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
# ABSTRACT: Get table data from an array of arrays |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |