Layout/Line.pm

filter: Statementstmt 100% 41 / 41 Branchbran 78.5% 11 / 14 Conditioncond 85.7% 6 / 7 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 3 totaltotal 88.4% 69 / 78 CC 11 SCAR 10.8
CC
11
Cov
94%
new
5.2
previous_line
3.0
next_line
3.0
CRAP 2.9
« Layout/Render.pm ↑ Summary Layout/LineSection.pm »
1 #_{ Encoding and name
2 =encoding utf8
3 =head1 NAME
4  
5 Grid::Layout::Line
6  
7 =cut
8 #_}
9 package Grid::Layout::Line;
10 #_{ use …
11 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 #_}
17 5 our $VERSION = 0.01;
18 #_{ Synopsis
19  
20 =head1 SYNOPSIS
21 =cut
22 #_}
23 #_{ Description
24  
25 =head1 DESCRIPTION
26  
27 A C<< Grid::Layout::Line >> is an indefinitismal thin line that runs either
28 horizontally or vertically from one end of a grid to the other.
29  
30 The
31  
32 Of course, when the grid is rendered, the line might become thicker than indefinitismal thin (think border).
33  
34 =cut
35 #_}
36 #_{ Methods
37 #_{ POD
38 =head1 METHODS
39 =cut
40 #_}
41 54 ▶sub new { #_{
Subroutine new: called CC=5 SCAR=16.4
Pod undocumented
42 #_{ POD
43 =head2 new
44  
45 my $line = Grid::Layout::Line->new($V_or_H);
46  
47 This function should not be called by a user. It is called by L<< Grid::Layout/_add_line >>.
48  
49 =cut
50 #_}
51  
52 54 my $class = shift;
53 54 my $grid_layout = shift;
54 54 my $V_or_H = shift; # TODO not used...
55 54 my $position = shift;
56  
57 54 ▶ croak "need a Grid::Layout" unless $grid_layout->isa('Grid::Layout');
Branch: 1 branch
BranchTrueFalseTotal
unless $grid_layout->isa("Grid::Layout") 0 54 54
58 54 ▶ croak "need a V or an H" unless $V_or_H eq 'V' or $V_or_H eq 'H';
Branch: 1 branch
BranchTrueFalseTotal
unless $V_or_H eq "V" or $V_or_H eq "H" 0 54 54
Condition66%2/3
$V_or_H eq "V" or $V_or_H eq "H"
l!l&&r!l&&!r
27270
MC/DC0%0/2
$V_or_H eq "V" or $V_or_H eq "H"
$V_or_H eq "V" $V_or_H eq "H"
Truth table66%2/3
A or B
A= $V_or_H eq "V"B= $V_or_H eq "H"
ABresult
1X1
011
000
59 54 ▶ croak "need a position" unless $position =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $position =~ /^\d+$/ 0 54 54
60  
61 54 my $self = {};
62 54 bless $self, $class;
63  
64 54 $self->{grid_layout} = $grid_layout;
65 54 $self->{V_or_H } = $V_or_H;
66 54 $self->{position } = $position;
67 54 return $self;
68  
69 } #_}
70 12 ▶sub _previous_track { #_{
Subroutine _previous_track: called CC=2 SCAR=6.9
71  
72 12 my $self = shift;
73
74 12 ▶ croak 'Cannot return previous track, I am line zero' unless $self->{position};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"position"} 2 10 12
75  
76 10 return $self->{grid_layout}->_track($self->{V_or_H}, $self->{position}-1);
77  
78 } #_}
79 13 ▶sub _next_track { #_{
Subroutine _next_track: called CC=2 SCAR=6.9
80  
81 13 my $self = shift;
82  
83 13 ▶ croak 'Cannot return next track, I am last line' unless $self->{position} < $self->{grid_layout}->_size($self->{V_or_H});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"position"} < $self->{"grid_layout"}->_size($self->{"V_or_H"}) 3 10 13
84  
85 10 return $self->{grid_layout}->_track($self->{V_or_H}, $self->{position});
86  
87 } #_}
88 18 ▶sub previous_line { #_{
Subroutine previous_line: called CC=3 SCAR=11.0
Pod undocumented
89  
90 18 my $self = shift;
91 18 ▶ my $dist = shift // 1;
Condition100%2/2
shift() // 1
l!l
144
MC/DC100%1/1
shift() // 1
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
92
93 18 ▶ croak "Cannot return previous line $dist, I am line $self->{position}" unless $self->{position}-$dist >= 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"position"} - $dist >= 0 4 14 18
94  
95 14 return $self->{grid_layout}->_line($self->{V_or_H}, $self->{position}-$dist);
96  
97 } #_}
98 18 ▶sub next_line { #_{
Subroutine next_line: called CC=3 SCAR=11.0
Pod undocumented
99  
100 18 my $self = shift;
101 18 ▶ my $dist = shift // 1;
Condition100%2/2
shift() // 1
l!l
144
MC/DC100%1/1
shift() // 1
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
102  
103 18 ▶ croak "Cannot return next line $dist, I am line $self->{position} and the size is " . $self->{grid_layout}->_size($self->{V_or_H}) unless $self->{position}+$dist <= $self->{grid_layout}->_size($self->{V_or_H});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"position"} + $dist <= $self->{"grid_layout"}->_size($self->{"V_or_H"}) 4 14 18
104  
105 14 return $self->{grid_layout}->_line($self->{V_or_H}, $self->{position}+$dist);
106  
107 } #_}
108 #_}
109 #_{ POD: Copyright
110  
111 =head1 Copyright
112  
113 Copyright © 2017 René Nyffenegger, Switzerland. All rights reserved.
114 This program is free software; you can redistribute it and/or modify it
115 under the terms of the the Artistic License (2.0). You may obtain a
116 copy of the full license at: L<http://www.perlfoundation.org/artistic_license_2_0>
117  
118 =cut
119  
120 #_}
121  
122 5 'tq84';
« Layout/Render.pm ↑ Summary Layout/LineSection.pm »