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