File Coverage

blib/lib/DR/R.pm
Criterion Covered Total %
statement 36 36 100.0
branch 11 12 91.6
condition 3 4 75.0
subroutine 7 7 100.0
pod 1 1 100.0
total 58 60 96.6


line stmt bran cond sub pod time code
1             package DR::R;
2              
3 5     5   394957 use 5.010001;
  5         19  
4 5     5   26 use strict;
  5         11  
  5         103  
5 5     5   25 use utf8;
  5         15  
  5         29  
6 5     5   134 use warnings;
  5         9  
  5         153  
7              
8 5     5   29 use Carp;
  5         11  
  5         1648  
9             our $VERSION = '0.02';
10              
11             require XSLoader;
12             XSLoader::load('DR::R', $VERSION);
13              
14             sub select :method {
15 6     6 1 947105 my ($self, $type, $point_or_rect, %opts) = @_;
16              
17 6   100     43 my $offset = $opts{offset} || 0;
18 6         12 my $limit = $opts{limit};
19 6         12 my @result;
20              
21 6         10 my $type_ok = 0;
22 6   50     17 $type //= '';
23 6         11 for (@{ $self->iterator_types }) {
  6         39  
24 48 100       130 if ($type eq $_) {
25 5         8 $type_ok = 1;
26 5         12 last;
27             }
28             }
29 6 100       238 croak "Unknown iterator type: '$type'" unless $type_ok;
30 5 100       36 unless ($self->is_point_or_rect($point_or_rect)) {
31 3         370 croak "Invalid point or rect";
32             }
33              
34              
35             $self->foreach($type, $point_or_rect, sub {
36 21     21   39 my ($o, $id, $toffset) = @_;
37              
38 21 100       38 return if $toffset < $offset;
39 20         31 push @result => $o;
40 20 50       35 return unless defined $limit;
41 20 100       54 return if @result < $limit;
42 2         8 return 0;
43 2         40 });
44 2         22 return \@result;
45             }
46              
47             1;
48             __END__