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