/usr/share/perl5/Catmandu/Hits.pm is in libcatmandu-perl 0.9505-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | package Catmandu::Hits;
use Catmandu::Sane;
our $VERSION = '0.9505';
use Moo;
use namespace::clean;
has start => (is => 'ro', required => 1);
has limit => (is => 'ro', required => 1);
has total => (is => 'ro', required => 1);
has hits => (is => 'ro', required => 1);
with 'Catmandu::Iterable';
with 'Catmandu::Paged';
sub size {
scalar @{$_[0]->hits};
}
sub more {
my $self = $_[0];
$self->start + $self->limit < $self->total;
}
sub generator {
my $self = $_[0];
my $hits = $self->hits;
my $i = 0;
sub {
$hits->[$i++];
};
}
sub to_array {
[@{$_[0]->hits}];
}
sub count {
scalar @{$_[0]->hits};
}
sub each {
my ($self, $cb) = @_;
my $hits = $self->hits;
for my $hit (@$hits) {
$cb->($hit);
}
$self->count;
}
sub first {
$_[0]->hits->[0];
}
1;
__END__
=pod
=head1 NAME
Catmandu::Hits - Iterable object that wraps Catmandu::Store search hits
=head1 SYNOPSIS
my $store = Catmandu::Store::Solr->new();
my $hits = $store->bag->search(
query => 'dna' ,
start => 0 ,
limit => 100 ,
sort => 'title desc',
);
# Every hits is an iterator...
$hits->each(sub { ... });
printf "Found %s $hits\n" , $hits->total;
my $start = $hits->start;
my $limit = $hits->limit;
my $prev = $hits->previous_page;
my $next = $hits->next_page;
=head1 METHODS
=head2 total
Returns the total number of hits matching the query.
=head2 start
Returns the start index for the search results.
=head2 limit
Returns the maximum number of search results returned.
=head2 more
Return true if there are more search results.
=head1 SEE ALSO
L<Catmandu::Iterable>, L<Catmandu::Bag>, L<Catmandu::Searchable>, L<Catmandu::Store>, L<Catmandu::Paged>
=cut
|