line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Object::FromData::Array; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
14
|
use strict; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
61
|
|
4
|
3
|
|
|
3
|
|
7
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
792
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub _new { |
7
|
4
|
|
|
4
|
|
5
|
my ( $class, $arg_for ) = @_; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
|
|
4
|
my $arrayref = $arg_for->{ref}; |
10
|
4
|
|
|
|
|
4
|
my @array; |
11
|
4
|
|
|
|
|
7
|
my $self = { |
12
|
|
|
|
|
|
|
array => \@array, |
13
|
|
|
|
|
|
|
current_index => 0, |
14
|
|
|
|
|
|
|
}; |
15
|
4
|
|
|
|
|
8
|
foreach my $item (@$arrayref) { |
16
|
16
|
100
|
|
|
|
24
|
if ( 'ARRAY' eq ref $item ) { |
|
|
50
|
|
|
|
|
|
17
|
1
|
|
|
|
|
5
|
push @array => $class->_new( { ref => $item } ); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
elsif ( 'HASH' eq ref $item ) { |
20
|
0
|
|
|
|
|
0
|
push @array => Object::FromData::Hash->_new( { ref => $item } ); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
else { |
23
|
15
|
|
|
|
|
17
|
push @array => $item; # accept it raw |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
4
|
|
|
|
|
13
|
return bless $self => $class; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub current_index { |
30
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
31
|
0
|
|
|
|
|
0
|
return $self->{current_index}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub num_elems { |
35
|
4
|
|
|
4
|
1
|
17
|
my $self = shift; |
36
|
4
|
|
|
|
|
3
|
return scalar @{ $self->{array} }; |
|
4
|
|
|
|
|
17
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub reset { |
40
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
41
|
1
|
|
|
|
|
2
|
$self->{current_index} = 0; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub all { |
45
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
46
|
0
|
|
|
|
|
0
|
return @{ $self->{array} }; |
|
0
|
|
|
|
|
0
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub has_more { |
50
|
19
|
|
|
19
|
1
|
1185
|
my $self = shift; |
51
|
19
|
|
|
|
|
17
|
my $arrayref = $self->{array}; |
52
|
19
|
|
|
|
|
58
|
return $self->{current_index} <= $#$arrayref; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub next { |
56
|
13
|
|
|
13
|
1
|
18
|
my $self = shift; |
57
|
13
|
50
|
|
|
|
19
|
return unless $self->has_more; |
58
|
13
|
|
|
|
|
34
|
return $self->{array}->[ $self->{current_index}++ ]; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
0
|
1
|
|
sub is_hashref { } |
62
|
0
|
|
|
0
|
1
|
|
sub is_arrayref {1} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |