| 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
| |||||||||||||||||||||||||||||
| 58 | 54 | ▶ | croak "need a V or an H" unless $V_or_H eq 'V' or $V_or_H eq 'H'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$V_or_H eq "V" or $V_or_H eq "H"
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"
| |||||||||||||||||||||||||||||
| 59 | 54 | ▶ | croak "need a position" unless $position =~ /^\d+$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
MC/DC100%1/1
shift() // 1
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 18 | ▶ | croak "Cannot return previous line $dist, I am line $self->{position}" unless $self->{position}-$dist >= 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
MC/DC100%1/1
shift() // 1
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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'; | |||||||||||||||||||||||||||