line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TableDataRole::Source::AOA; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
666
|
use 5.010001; |
|
2
|
|
|
|
|
6
|
|
4
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
30
|
|
5
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
44
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
8
|
use Role::Tiny; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
9
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
10
|
|
|
|
|
|
|
our $DATE = '2022-02-20'; # DATE |
11
|
|
|
|
|
|
|
our $DIST = 'TableDataRoles-Standard'; # DIST |
12
|
|
|
|
|
|
|
our $VERSION = '0.014'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
with 'TableDataRole::Spec::Basic'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
2
|
|
|
2
|
0
|
90
|
my ($class, %args) = @_; |
18
|
|
|
|
|
|
|
|
19
|
2
|
50
|
|
|
|
9
|
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
|
|
|
|
7
|
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
|
|
|
|
|
5
|
column_idxs => {map {$column_names->[$_] => $_} 0..$#{$column_names}}, |
|
5
|
|
|
|
|
23
|
|
|
2
|
|
|
|
|
6
|
|
29
|
|
|
|
|
|
|
}, $class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub get_column_count { |
33
|
2
|
|
|
2
|
0
|
10
|
my $self = shift; |
34
|
2
|
|
|
|
|
2
|
scalar @{ $self->{column_names} }; |
|
2
|
|
|
|
|
16
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub get_column_names { |
38
|
2
|
|
|
2
|
0
|
4
|
my $self = shift; |
39
|
2
|
50
|
|
|
|
7
|
wantarray ? @{ $self->{column_names} } : $self->{column_names}; |
|
2
|
|
|
|
|
13
|
|
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
|
4
|
my $self = shift; |
49
|
2
|
|
|
|
|
4
|
my $aoa = $self->{aoa}; |
50
|
2
|
50
|
|
|
|
3
|
die "StopIteration" unless $self->{pos} < @{$aoa}; |
|
2
|
|
|
|
|
7
|
|
51
|
2
|
|
|
|
|
9
|
$aoa->[ $self->{pos}++ ]; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub get_next_row_hashref { |
55
|
4
|
|
|
4
|
0
|
7
|
my $self = shift; |
56
|
4
|
|
|
|
|
7
|
my $aoa = $self->{aoa}; |
57
|
4
|
50
|
|
|
|
5
|
die "StopIteration" unless $self->{pos} < @{$aoa}; |
|
4
|
|
|
|
|
12
|
|
58
|
4
|
|
|
|
|
6
|
my $row_aryref = $aoa->[ $self->{pos}++ ]; |
59
|
4
|
|
|
|
|
7
|
+{ map { $self->{column_names}[$_] => $row_aryref->[$_] } 0..$#{$self->{column_names}} }; |
|
10
|
|
|
|
|
33
|
|
|
4
|
|
|
|
|
8
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub get_row_count { |
63
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
64
|
2
|
|
|
|
|
3
|
scalar(@{ $self->{aoa} }); |
|
2
|
|
|
|
|
8
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub reset_iterator { |
68
|
4
|
|
|
4
|
0
|
8
|
my $self = shift; |
69
|
4
|
|
|
|
|
7
|
$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__ |