blib/lib/Set/Associate/NewKey/PickOffset.pm

filter: Statementstmt 95.8% 23 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod 100% 2 / 2 totaltotal 94.1% 32 / 34 CC 1 SCAR 1.2
CC
1
Cov
96%
name
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« lib/Set/Associate/RefillItems/Linear.pm ↑ Summary lib/Set/Associate/RefillItems/Shuffle.pm »
1 9 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Set::Associate::NewKey::PickOffset;
6  
7 # ABSTRACT: Associate a key with a value from a pool based on the keys value as a numeric offset.
8  
9 9 our $VERSION = '0.004000';
10  
11 9 our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12  
13 9 ▶use Moose qw( with );
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 9 with 'Set::Associate::Role::NewKey' => { can_get_assoc => 1, };
16  
17 9 __PACKAGE__->meta->make_immutable;
18  
19 9 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21  
22  
23  
24  
25  
26  
27 0 ▶sub name { 'pick_offset' }
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39 sub get_assoc {
40 9 ▶ use bigint;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 28 ▶ return $_[1]->_items_cache_get( $_[2] % $_[1]->_items_cache_count );
Subroutine get_assoc: called CC=1 SCAR=0.0
Pod documented
42 }
43  
44 9 1;
45  
46 __END__
47  
48 =pod
49  
50 =encoding UTF-8
51  
52 =head1 NAME
53  
54 Set::Associate::NewKey::PickOffset - Associate a key with a value from a pool based on the keys value as a numeric offset.
55  
56 =head1 VERSION
57  
58 version 0.004000
59  
60 =head1 METHODS
61  
62 =head2 name
63  
64 The name of this key assignment method ( C<pick_offset> )
65  
66 =head2 get_assoc
67  
68 Returns a value non-destructively by picking an item at numerical offset C<$new_key>
69  
70 my $value = $object->get_assoc( $set_assoc, $new_key );
71  
72 B<Note:> C<$new_key> is automatically modulo of the length of C<$set_assoc>, so offsets beyond end of array are safe, and wrap.
73  
74 =head1 AUTHOR
75  
76 Kent Fredric <kentnl@cpan.org>
77  
78 =head1 COPYRIGHT AND LICENSE
79  
80 This software is copyright (c) 2015 by Kent Fredric <kentfredric@gmail.com>.
81  
82 This is free software; you can redistribute it and/or modify it under
83 the same terms as the Perl 5 programming language system itself.
84  
85 =cut
« lib/Set/Associate/RefillItems/Linear.pm ↑ Summary lib/Set/Associate/RefillItems/Shuffle.pm »