NG/Excel/Sheet.pm

filter: Statementstmt 44.4% 16 / 36 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 45.4% 5 / 11 Podpod 0.0% 0 / 5 totaltotal 36.2% 21 / 58 CC 4 SCAR 12.1
CC
4
Cov
38%
name
6.0
get
6.0
_letter_to_num
6.0
CRAP 3.4
« NG/Log.pm ↑ Summary NG/Autobox/String.pm »
1 package NG::Excel::Sheet;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use NG::Array;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use NG::Excel::Cell;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use base qw(NG::Object);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
9 0 my ( $pkg, @config ) = @_;
10 0 my $sheet = {
11 name => 'no name',
12 cells => NG::Array->new( NG::Array->new ),
13 row_count => 0,
14 col_count => 0,
15 @config,
16 };
17 0 return bless $sheet, $pkg;
18 }
19  
20 0 ▶sub row_count { return shift->{row_count}; }
Subroutine row_count: not called CC=1 SCAR=6.9
Pod undocumented
21  
22 0 ▶sub col_count { return shift->{col_count}; }
Subroutine col_count: not called CC=1 SCAR=6.9
Pod undocumented
23  
24 0 ▶sub name {
Subroutine name: not called CC=2 SCAR=17.9
Pod undocumented
25 0 my ( $self, $new_val ) = @_;
26 0 ▶ if ( defined $new_val ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_val) { } 0 0 0
27 0 $self->{name} = $new_val;
28 0 return $self;
29 }
30 else {
31 0 return $self->{name};
32 }
33 }
34  
35 0 ▶sub get {
Subroutine get: not called CC=2 SCAR=17.9
Pod undocumented
36 0 my ( $self, $row, $col ) = @_;
37 0 ▶ if ( $col =~ /^[A-Za-z]+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($col =~ /^[A-Za-z]+$/) 0 0 0
38 0 $col = _letter_to_num($col);
39 }
40 0 return $self->{cells}->[ $row - 1 ][ $col - 1 ];
41 }
42  
43 0 ▶sub _letter_to_num {
Subroutine _letter_to_num: not called CC=2 SCAR=17.9
44 0 my $str = shift;
45 0 my $letters = NG::Array->new( split //, uc($str) );
46 0 my $res = 0;
47 0 ▶ for ( my $i = ( $letters->size ) - 1 ; $i >= 0 ; $i-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 0) 0 0 0
48 0 $res +=
49 ( ( ord( $letters->[$i] ) - ord('A') + 1 ) *
50 ( 26**( $letters->size - $i - 1 ) ) );
51 }
52 0 return $res;
53 }
54  
55 1 1;
« NG/Log.pm ↑ Summary NG/Autobox/String.pm »