blib/lib/CXC/Gnuplot/V1/CoordOffset3D.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/V1/CoordOffset2D.pm ↑ Summary blib/lib/CXC/Gnuplot/V1/CoordPosition2D.pm »
1 package CXC::Gnuplot::V1::CoordOffset3D;
2  
3 1 ▶use v5.38;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use experimental '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::CoordOffset3D
10 : isa( CXC::Gnuplot::V1::Base )
11 : does( CXC::Gnuplot::V1::Role::Clone );
12  
13 no namespace::clean;
14  
15 use Ref::Util 'is_plain_hashref';
16  
17 use namespace::clean;
18  
19 use CXC::Gnuplot::V1::Types -lexical => 'CoordValue';
20  
21 use CXC::Gnuplot::V1::Util
22 -lexical => 'pvalidate',
23 'to_hash_r';
24  
25 #<<< no tidy
26 field $x :param :reader //= 0;
27 field $y :param :reader //= 0;
28 field $z :param :reader //= 0;
29 field $opts ;
30 #>>>
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47 ADJUST {
48 pvalidate( x => CoordValue, \$x );
49 pvalidate( y => CoordValue, \$y );
50 pvalidate( z => CoordValue, \$z );
51 }
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66 method BUILDARGS : common (@args ) {
67 return ( x => $args[0] ) if @args == 1 && !is_plain_hashref( $args[0] );
68 return $class->SUPER::BUILDARGS( @args );
69 }
70  
71  
72  
73  
74  
75  
76  
77  
78  
79 method to_hash ( %args ) {
80 to_hash_r( {
81 ( defined $x ? ( x => $x ) : () ), #
82 ( defined $y ? ( y => $y ) : () ),
83 ( defined $z ? ( z => $z ) : () ),
84 } );
85 }
86  
87  
88  
89  
90  
91 method opts {
92  
93 # remove trailing '0' offset coords with no coordsys
94 $opts //= do {
95 my @opts = map { $_->stringify } $x, $y, $z;
96 pop @opts while @opts && $opts[-1] eq '0';
97 join( q{,}, @opts );
98 };
99  
100 return length( $opts ) ? ( $opts ) : ();
101 }
102  
103 1;
104  
105 #
106 # This file is part of CXC-Gnuplot
107 #
108 # This software is Copyright (c) 2024 by Smithsonian Astrophysical Observatory.
109 #
110 # This is free software, licensed under:
111 #
112 # The GNU General Public License, Version 3, June 2007
113 #
114  
115 __END__
« blib/lib/CXC/Gnuplot/V1/CoordOffset2D.pm ↑ Summary blib/lib/CXC/Gnuplot/V1/CoordPosition2D.pm »