blib/lib/CXC/Gnuplot/V1/Timestamp.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/Role/Clone.pm ↑ Summary blib/lib/CXC/Gnuplot/V1/Title.pm »
1 package CXC::Gnuplot::V1::Timestamp;
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::Timestamp : isa(CXC::Gnuplot::V1::Base)
10 does( CXC::Gnuplot::V1::Role::Clone );
11  
12 use builtin 'is_bool', 'true', 'false';
13  
14 use CXC::Gnuplot::V1::Types -lexical, qw(
15 Enum
16 is_Num
17 CoordOffset2D
18 SetFormats
19  
20 signature_for
21 );
22  
23 use CXC::Gnuplot::V1::Util -lexical, 'maybe_quote', 'pvalidate', 'to_hash_r', 'render_opts',
24 'render_set';
25  
26 use CXC::Gnuplot::V1::AxisFormat;
27  
28  
29 my sub croak {
30 require Carp;
31 goto \&Carp::croak;
32 }
33  
34 #<<< no tidy
35 field $format :param :reader = undef; #
36 field $where :param :reader = undef; # {top | bottom}
37 field $rotate :param :reader = undef; # {{no}rotate {by <ang>}}
38 field $offset :param :reader = undef; # {offset <offset> }
39 field $font :param :reader = undef; # {"name{,<size>}"}
40 field $textcolor :param :reader = undef; # {colorspec}
41 #>>>
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65 ADJUST {
66  
67 pvalidate( format => Str => \$format );
68  
69 pvalidate( where => Enum->of( 'top', 'bottom' ), \$where );
70  
71 defined $rotate
72 and !is_bool( $rotate )
73 and !is_Num( $rotate )
74 and croak( '"rotate" must be a float or a boolean' );
75  
76 pvalidate( offset => CoordOffset2D, \$offset );
77 pvalidate( font => Font => \$font );
78 pvalidate( textcolor => ColorSpec => \$textcolor );
79 }
80  
81  
82  
83  
84  
85 method to_hash {
86  
87 to_hash_r( {
88 ( defined $format ? ( format => $format ) : () ),
89 ( defined $where ? ( where => $where ) : () ),
90 ( defined $rotate ? ( rotate => $rotate ) : () ),
91 ( defined $offset ? ( offset => $offset ) : () ),
92 ( defined $font ? ( font => $font ) : () ),
93 ( defined $textcolor ? ( textcolor => $textcolor ) : () ),
94 } );
95 }
96  
97  
98  
99  
100  
101 method opts {
102 my @opts;
103  
104 defined $format
105 and push @opts, maybe_quote( $format );
106  
107  
108 defined $where
109 and push @opts, $where;
110  
111 defined $offset
112 and push @opts, render_opts( offset => $offset );
113  
114 defined $rotate
115 and push @opts, is_bool( $rotate )
116 ? ( $rotate ? 'rotate' : 'norotate' )
117 : [ 'rotate by' => $rotate ];
118  
119  
120 push @opts, render_opts( font => $font );
121  
122 push @opts, render_opts( textcolor => $textcolor );
123  
124 return @opts;
125 }
126  
127  
128  
129  
130  
131 signature_for set => (
132 method => 1,
133 named => [
134 as => SetFormats,
135 { default => 'string' },
136 ],
137 );
138  
139 method set ( $opt ) {
140 return render_set( [ render_opts( [ set => 'timestamp' ], $self ) ], $opt->as );
141 }
142  
143  
144 #
145 # This file is part of CXC-Gnuplot
146 #
147 # This software is Copyright (c) 2024 by Smithsonian Astrophysical Observatory.
148 #
149 # This is free software, licensed under:
150 #
151 # The GNU General Public License, Version 3, June 2007
152 #
153  
154 1;
155  
156 __END__
« blib/lib/CXC/Gnuplot/V1/Role/Clone.pm ↑ Summary blib/lib/CXC/Gnuplot/V1/Title.pm »