blib/lib/CXC/Gnuplot/V1/Axis.pm

filter: Statementstmt 75.0% 6 / 8 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 81.8% 9 / 11 CC 1 SCAR 0.9
CC
1
Cov
75%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« blib/lib/CXC/Gnuplot/V0/Terminal/pdfcairo.pm ↑ Summary blib/lib/CXC/Gnuplot/V1/AxisLabel.pm »
1 package CXC::Gnuplot::V1::Axis;
2  
3 1 ▶use v5.38;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use experimental 'builtin', 'declared_refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Object::Pad 0.821;
Subroutine BEGIN: called CC=1 SCAR=2.6
6  
7 our $VERSION = 'v0.29.3';
8  
9 class CXC::Gnuplot::V1::Axis : isa(CXC::Gnuplot::V1::Base) does( CXC::Gnuplot::V1::Role::Clone );
10  
11 no namespace::clean;
12  
13 use Syntax::Operator::Elem 'elem_str';
14 use namespace::clean;
15  
16 use builtin 'is_bool', 'true';
17  
18 use CXC::Gnuplot::V1::AxisFormat;
19 use CXC::Gnuplot::V1::Types
20 -lexical => 'is_PositiveNum',
21 'NonEmptyStr', 'SetFormats', 'signature_for';
22  
23 use CXC::Gnuplot::V1::Util
24 -lexical => 'pvalidate',
25 'to_hash_r', 'render_opts',
26 'render_set';
27  
28 my sub croak {
29 require Carp;
30 goto \&Carp::croak;
31 }
32  
33 #<<< no tidy
34 field $range :param :reader = undef;
35 field $label :param :reader = undef;
36 field $format :param :reader = undef;
37 field $logscale :param :reader = undef;
38 field $logscalebase :param :reader = undef;
39 field $data :param :reader = undef;
40 field $tics :param :reader = undef;
41 field $mtics :param :reader = undef;
42  
43 #>>>
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69 ADJUST {
70  
71 pvalidate( format => AxisFormat => \$format );
72  
73 pvalidate( range => AxisRange => \$range );
74 pvalidate( label => AxisLabel => \$label );
75  
76 defined $tics
77 and !is_bool( $tics )
78 and pvalidate( tics => AxisTics => \$tics );
79  
80 defined $mtics
81 and !is_bool( $mtics )
82 and pvalidate( mtics => AxisMinorTics => \$mtics );
83  
84 #<<< no tidy
85 defined $data
86 and ! elem_str( $data, 'normal', 'time' )
87 and croak( q{invalid value for "data" parameter} );
88 #>>>
89  
90 defined $logscale
91 and !is_bool( $logscale )
92 and croak( q{invalid value for "logscale" parameter; must be bool} );
93  
94 defined $logscalebase
95 and !is_PositiveNum( $logscalebase )
96 and croak( q{invalid value for "logscalebase" parameter; must be positive float} );
97  
98 }
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119 method to_hash {
120  
121 to_hash_r( {
122 ( defined $range ? ( range => $range ) : () ),
123 ( defined $label ? ( label => $label ) : () ),
124 ( defined $format ? ( format => $format ) : () ),
125 ( defined $logscale ? ( logscale => $logscale ) : () ),
126 ( defined $logscalebase ? ( logscalebase => $logscalebase ) : () ),
127 ( defined $data ? ( data => $data ) : () ),
128 ( defined $tics ? ( tics => $tics ) : () ),
129 ( defined $mtics ? ( mtics => $mtics ) : () ),
130 } );
131 }
132  
133  
134  
135  
136  
137 signature_for set => (
138 method => 1,
139 head => [NonEmptyStr],
140 named => [
141 as => SetFormats,
142 { default => 'string' },
143 ],
144 );
145  
146 method set( $axis, $opt ) {
147  
148 ## no critic(NamingConventions::ProhibitAmbiguousNames)
149 my @set;
150  
151 push @set, $range->set( $axis, as => $opt->as )
152 if defined $range;
153  
154 push @set, render_opts( [ set => $axis . 'label' ], $label );
155  
156 push @set, render_opts( [ set => 'format', $axis ], $format );
157  
158 if ( defined $tics ) {
159 my $key = $axis . 'tics';
160 push @set, is_bool( $tics )
161 ? $tics
162 ? [ set => $key ]
163 : [ unset => $key ]
164 : render_opts( [ set => $key ], $tics );
165 }
166  
167 if ( defined $mtics ) {
168 my $key = 'm' . $axis . 'tics';
169 push @set, is_bool( $mtics )
170 ? $mtics
171 ? [ set => $key ]
172 : [ unset => $key ]
173 : render_opts( [ set => $key ], $mtics );
174 }
175  
176 push @set, [ set => $axis . 'data', ( $data eq 'normal' ? () : $data ) ]
177 if defined $data;
178  
179 push @set, [ set => 'logscale', [ $axis, defined $logscalebase ? $logscalebase : () ] ]
180 if defined $logscale && $logscale;
181  
182 return render_set( \@set, $opt->as );
183 }
184  
185  
186 1;
187  
188 #
189 # This file is part of CXC-Gnuplot
190 #
191 # This software is Copyright (c) 2024 by Smithsonian Astrophysical Observatory.
192 #
193 # This is free software, licensed under:
194 #
195 # The GNU General Public License, Version 3, June 2007
196 #
197  
198 __END__
« blib/lib/CXC/Gnuplot/V0/Terminal/pdfcairo.pm ↑ Summary blib/lib/CXC/Gnuplot/V1/AxisLabel.pm »