Block.pm

filter: Statementstmt 97.2% 35 / 36 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 96.0% 49 / 51 CC 4 SCAR 5.9
CC
4
Cov
95%
_count
3.0
next
2.0
BEGIN
1.0
CRAP 1.8
« Block/Item.pm ↑ Summary
1 package Unicode::Block;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Class::Utils qw(set_params_pub);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Unicode::Block::Item;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 our $VERSION = 0.07;
10  
11 # Constructor.
12 sub new {
13 4 ▶ my ($class, @params) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
14  
15 # Create object.
16 4 my $self = bless {}, $class;
17  
18 # Character from.
19 $self->{'char_from'} = '0000',
20  
21 # Character to.
22 $self->{'char_to'} = '007F',
23  
24 # Title.
25 4 $self->{'title'} = undef;
26  
27 # Process parameters.
28 4 set_params_pub($self, @params);
29  
30 # Count.
31 2 $self->{'_count'} = $self->{'char_from'};
32  
33 # Object.
34 2 return $self;
35 }
36  
37 # Get next character.
38 sub next {
39 2 ▶ my $self = shift;
Subroutine next: called CC=2 SCAR=6.9
Pod documented
40 2 my $char_hex = $self->_count;
41 2 ▶ if (defined $char_hex) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $char_hex) { } 1 1 2
42 1 return Unicode::Block::Item->new('hex' => $char_hex);
43 } else {
44 1 return;
45 }
46 }
47  
48 # Get actual character and increase number.
49 sub _count {
50 2 ▶ my $self = shift;
Subroutine _count: called CC=3 SCAR=11.1
51 2 my $ret = $self->{'_count'};
52 2 ▶ if (! defined $ret) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret) 1 1 2
53 1 return;
54 }
55 1 my $num = hex $self->{'_count'};
56 1 $num++;
57 1 my $last_num = hex $self->{'char_to'};
58 1 ▶ if ($num > $last_num) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num > $last_num) { } 1 0 1
59 1 $self->{'_count'} = undef;
60 } else {
61 0 $self->{'_count'} = sprintf '%x', $num;
62 }
63 1 return $ret;
64 }
65  
66 4 1;
67  
68 __END__
« Block/Item.pm ↑ Summary