blib/lib/CXC/Gnuplot/V1/MultiPlot/Margins.pm

filter: Statementstmt 60.0% 3 / 5 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 71.4% 5 / 7 CC 1 SCAR 1.4
CC
1
Cov
60%
BEGIN
1.3
BEGIN
1.0
CRAP 1.1
« blib/lib/CXC/Gnuplot/V1/Margin.pm ↑ Summary blib/lib/CXC/Gnuplot/V1/TermOptions.pm »
1 package CXC::Gnuplot::V1::MultiPlot::Margins;
2  
3 1 ▶use v5.38;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Object::Pad 0.821;
Subroutine BEGIN: called CC=1 SCAR=2.6
5 use experimental 'builtin';
6  
7 our $VERSION = 'v0.29.3';
8  
9 class CXC::Gnuplot::V1::MultiPlot::Margins : isa(CXC::Gnuplot::V1::Base)
10 does( CXC::Gnuplot::V1::Role::Clone );
11  
12 use builtin 'is_bool', 'false';
13  
14 use CXC::Gnuplot::V1::Util
15 -lexical => 'pvalidate',
16 'to_hash_r';
17 use CXC::Gnuplot::V1::Types -lexical => qw( Num );
18  
19 my sub croak {
20 require Carp;
21 goto \&Carp::croak;
22 }
23  
24 #<<< no tidy
25 field $top :param :reader = undef;
26 field $bottom :param :reader = undef;
27 field $left :param :reader = undef;
28 field $right :param :reader = undef;
29 #>>>
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47 ADJUST {
48  
49 croak( 'all margins must be specified' )
50 unless defined $top
51 and defined $bottom
52 and defined $left
53 and defined $right;
54  
55 pvalidate( top => Num, \$top );
56 pvalidate( bottom => Num, \$bottom );
57 pvalidate( left => Num, \$left );
58 pvalidate( right => Num, \$right );
59 }
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80 method to_hash {
81  
82 to_hash_r( {
83 ( defined $top ? ( top => $top ) : () ),
84 ( defined $bottom ? ( bottom => $bottom ) : () ),
85 ( defined $left ? ( left => $left ) : () ),
86 ( defined $right ? ( right => $right ) : () ),
87 } );
88  
89 }
90  
91  
92  
93  
94  
95  
96 method opts {
97 # only use as many margins as specified.
98 # to specify a specific margin, use the [lrtb]margin commands
99 ## no critic (NamingConventions::ProhibitAmbiguousNames)
100 my @margins = ( $left, $right, $bottom, $top );
101 pop @margins while @margins && !defined $margins[-1];
102  
103 return ( @margins ? join( q{,}, @margins ) : () );
104 }
105  
106 1;
107  
108 #
109 # This file is part of CXC-Gnuplot
110 #
111 # This software is Copyright (c) 2024 by Smithsonian Astrophysical Observatory.
112 #
113 # This is free software, licensed under:
114 #
115 # The GNU General Public License, Version 3, June 2007
116 #
117  
118 __END__
« blib/lib/CXC/Gnuplot/V1/Margin.pm ↑ Summary blib/lib/CXC/Gnuplot/V1/TermOptions.pm »