File Coverage

blib/lib/Data/AutoBimap.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 7 7 100.0
pod 3 3 100.0
total 37 38 97.3


line stmt bran cond sub pod time code
1             package Data::AutoBimap;
2            
3 2     2   63788 use 5.012000;
  2         8  
  2         73  
4 2     2   11 use strict;
  2         3  
  2         65  
5 2     2   8 use warnings;
  2         7  
  2         69  
6 2     2   9 use base qw(Exporter);
  2         5  
  2         1405  
7            
8             our $VERSION = '0.03';
9            
10             our %EXPORT_TAGS = ( 'all' => [ qw(
11            
12             ) ] );
13            
14             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
15            
16             our @EXPORT = qw(
17             );
18            
19             sub new {
20 1     1 1 16 my ($class, %options) = @_;
21            
22 1   50     10 $options{start} //= 1;
23            
24 1         7 my $self = {
25             next => $options{start},
26             s2n => {},
27             n2s => [],
28             };
29            
30 1         5 bless $self, $class;
31             }
32            
33             sub s2n {
34 3     3 1 9 my ($self, $s) = @_;
35            
36 3 100       15 unless (exists $self->{s2n}{$s}) {
37 2         6 $self->{s2n}{$s} = $self->{next};
38 2         5 $self->{n2s}[$self->{next}] = $s;
39 2         3 $self->{next}++;
40             }
41            
42 3         16 return $self->{s2n}{$s};
43             }
44            
45             sub n2s {
46 2     2 1 4 my ($self, $n) = @_;
47 2         9 return $self->{n2s}[$n];
48             }
49            
50             1;
51            
52             __END__