Layout/Render.pm

filter: Statementstmt 100% 31 / 31 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 89.1% 41 / 46 CC 7 SCAR 15.4
CC
7
Cov
90%
top_to_bottom_left_to_right
7.3
BEGIN
1.0
BEGIN
1.0
CRAP 4.7
« Layout/Area.pm ↑ Summary Layout/Line.pm »
1 #_{ Encoding and name
2 =encoding utf8
3 =head1 NAME
4  
5 Grid::Layout::Area
6  
7 =cut
8 #_}
9 package Grid::Layout::Render;
10 #_{ use …
11 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 4 ▶use Grid::Layout;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 #_}
19 4 our $VERSION = $Grid::Layout::VERSION;
20 #_{ Synopsis
21  
22 =head1 SYNOPSIS
23  
24 C<Grid::Layout::Render> iterate over an L<< Grid::Layout >> and call appropriate call backs so as to render the grid on a device.
25  
26 =cut
27 #_}
28 #_{ Description
29  
30 =head1 DESCRIPTION
31  
32  
33 =cut
34 #_}
35 #_{ Methods
36 #_{ POD
37 =head1 METHODS
38 =cut
39 #_}
40 3 ▶sub top_to_bottom_left_to_right { #_{
Subroutine top_to_bottom_left_to_right: called CC=7 SCAR=19.9
Pod undocumented
41 #_{ POD
42 =head2 new
43  
44 use Grid::Layout;
45  
46 my $gl = Grid::Layout->new(…);
47  
48 Grid::Layout::Render::top_to_bottom_left_to_right(
49 $gl,
50 sub { # call back for next horizontal L<< track|Grid::Layout::Track >>.
51 my vertical_track = shift;
52 },
53 sub { # call back for each L<< cell|Grid::Layout::Cell> in the horizontal track
54 my $cell = shift;
55 },
56 sub { # call back when a horizontal track is finished
57 my vertical_track = shift;
58 }
59 );
60  
61 =cut
62 #_}
63  
64 3 my $gl = shift;
65 3 my $sub_next_track = shift;
66 3 my $sub_next_cell = shift;
67 3 my $sub_track_done = shift;
68  
69 3 ▶ croak "Need a Grid::Layout" unless $gl->isa('Grid::Layout');
Branch: 1 branch
BranchTrueFalseTotal
unless $gl->isa("Grid::Layout") 0 3 3
70 3 ▶ croak "Need a code ref for next track" unless ref($sub_next_track) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $sub_next_track eq "CODE" 0 3 3
71 3 ▶ croak "Need a code ref for next cell" unless ref($sub_next_cell ) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $sub_next_cell eq "CODE" 0 3 3
72 3 ▶ croak "Need a code ref for track done" unless ref($sub_track_done) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $sub_track_done eq "CODE" 0 3 3
73  
74 3 for my $track_h (@{$gl->{H}->{tracks}}) {
75 18 &$sub_next_track($track_h);
76  
77 18 for my $cell ($track_h->cells) {
78 116 &$sub_next_cell($cell);
79 }
80
81 18 &$sub_track_done($track_h);
82 }
83  
84 } #_}
85 #_}
86 #_{ POD: Copyright
87  
88 =head1 Copyright
89  
90 Copyright © 2017 René Nyffenegger, Switzerland. All rights reserved.
91 This program is free software; you can redistribute it and/or modify it
92 under the terms of the the Artistic License (2.0). You may obtain a
93 copy of the full license at: L<http://www.perlfoundation.org/artistic_license_2_0>
94  
95 =cut
96  
97 #_}
98  
99 4 'tq84';
100  
« Layout/Area.pm ↑ Summary Layout/Line.pm »