blib/lib/CXC/Gnuplot/V1/Margin.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/LiteralDataValue.pm ↑ Summary blib/lib/CXC/Gnuplot/V1/MultiPlot/Margins.pm »
1 package CXC::Gnuplot::V1::Margin;
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::Margin : isa(CXC::Gnuplot::V1::Base) does( CXC::Gnuplot::V1::Role::Clone );
10  
11 use builtin 'is_bool', 'true', 'false';
12  
13 use CXC::Gnuplot::V1::Util
14 -lexical => 'pvalidate',
15 'to_hash_r', 'render_set';
16  
17 use CXC::Gnuplot::V1::Types -lexical => qw(
18 Enum
19 Num
20 PerlBoolFalse
21 SetFormats
22 Tuple
23 signature_for
24 );
25  
26 use constant MarginValue => Num | PerlBoolFalse | Tuple [ Enum ['at'], Enum ['screen'], Num ];
27  
28 my sub croak {
29 require Carp;
30 goto \&Carp::croak;
31 }
32  
33 #<<< no tidy
34 field $top :param :reader = undef;
35 field $bottom :param :reader = undef;
36 field $left :param :reader = undef;
37 field $right :param :reader = undef;
38 #>>>
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56 ADJUST {
57 pvalidate( top => MarginValue, \$top );
58 pvalidate( bottom => MarginValue, \$bottom );
59 pvalidate( left => MarginValue, \$left );
60 pvalidate( right => MarginValue, \$right );
61 }
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82 method to_hash {
83  
84 to_hash_r( {
85 ( defined $top ? ( top => $top ) : () ),
86 ( defined $bottom ? ( bottom => $bottom ) : () ),
87 ( defined $left ? ( left => $left ) : () ),
88 ( defined $right ? ( right => $right ) : () ),
89 } );
90  
91 }
92  
93 my sub set_margin ( $label, $value ) {
94  
95 return unless defined $value;
96 return [ set => $label => is_bool( $value ) && !$value ? () : $value ];
97 }
98  
99  
100  
101  
102  
103  
104 signature_for set => (
105 method => 1,
106 named => [
107 as => SetFormats,
108 { default => 'string' },
109 ],
110 );
111  
112 method set ( $opt ) {
113  
114 ## no critic(NamingConventions::ProhibitAmbiguousNames)
115  
116 my @set = (
117 set_margin( lmargin => $left ),
118 set_margin( rmargin => $right ),
119 set_margin( bmargin => $bottom ),
120 set_margin( tmargin => $top ),
121 );
122  
123 return render_set( \@set, $opt->as );
124 }
125  
126 1;
127  
128 #
129 # This file is part of CXC-Gnuplot
130 #
131 # This software is Copyright (c) 2024 by Smithsonian Astrophysical Observatory.
132 #
133 # This is free software, licensed under:
134 #
135 # The GNU General Public License, Version 3, June 2007
136 #
137  
138 __END__
« blib/lib/CXC/Gnuplot/V1/LiteralDataValue.pm ↑ Summary blib/lib/CXC/Gnuplot/V1/MultiPlot/Margins.pm »