blib/lib/CXC/Gnuplot/V1/Key/Title.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/Key.pm ↑ Summary blib/lib/CXC/Gnuplot/V1/Label.pm »
1 package CXC::Gnuplot::V1::Key::Title;
2  
3 1 ▶use v5.38;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use experimental 'builtin';
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::Key::Title : isa(CXC::Gnuplot::V1::Base)
10 does( CXC::Gnuplot::V1::Role::Clone );
11  
12 use CXC::Gnuplot::V1::Types -lexical => qw(
13 Enum is_Str
14 );
15 use CXC::Gnuplot::V1::Util
16 -lexical => 'maybe_quote',
17 'pvalidate', 'to_hash_r', 'render_opts';
18  
19 use builtin 'is_bool';
20 use Lexical::Import qw( Ref::Util is_ref );
21  
22 my sub croak {
23 require Carp;
24 goto \&Carp::croak;
25 }
26  
27 #<<< no tidy
28 field $on :param :reader = undef;
29 field $text :param :reader = undef;
30 field $enhanced :param :reader = undef;
31 field $justify :param :reader = undef;
32 field $font :param :reader = undef;
33 field $textcolor :param :reader = undef;
34 #>>>
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57 ADJUST {
58  
59 # this is equivalent to 'set key notitle'
60 # $on => Bool
61 defined $on
62 and !is_bool( $on )
63 and croak( q{"on" parameter is not a Boolean} );
64  
65 # {font "<face>,<size>"}
66 # $font => Font|ArrayRef
67 pvalidate( font => Font => \$font );
68  
69 pvalidate( textcolor => ColorSpec => \$textcolor );
70  
71 # {{no}enhanced}
72 # $enhanced => Bool
73 defined $enhanced
74 and !is_bool( $enhanced )
75 and croak( q{invalid value for "enhanced" parameter; must be bool} );
76  
77 # $justify => [ left, center, right ]
78 pvalidate( justify => Enum->of( 'left', 'right', 'center' ), \$justify );
79 }
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95 method BUILDARGS : common (@args ) {
96 return ( text => $args[0] ) if @args == 1 && !is_ref( $args[0] );
97 return $class->SUPER::BUILDARGS( @args );
98 }
99  
100  
101  
102  
103  
104  
105  
106  
107 method to_hash {
108  
109 to_hash_r( {
110 ( defined $text ? ( text => $text ) : () ),
111 ( defined $on ? ( on => $on ) : () ),
112 ( defined $font ? ( font => $font ) : () ),
113 ( defined $enhanced ? ( enhanced => $enhanced ) : () ),
114 ( defined $textcolor ? ( textcolor => $textcolor ) : () ),
115 ( defined $justify ? ( justify => $justify ) : () ),
116 } );
117  
118 }
119  
120  
121  
122  
123  
124  
125 method opts {
126  
127 return 'notitle'
128 if defined $on and !$on
129 or defined $text and 0 == length( $text );
130  
131 my @opts;
132  
133 push @opts, maybe_quote( $text ) if defined $text;
134  
135 push @opts, render_opts( font => $font );
136  
137 push @opts, $enhanced ? 'enhanced' : 'noenhaced'
138 if defined $enhanced;
139  
140 push @opts, $justify if defined $justify;
141  
142 push @opts, render_opts( textcolor => $textcolor );
143  
144 return @opts;
145 }
146  
147 1;
148  
149 #
150 # This file is part of CXC-Gnuplot
151 #
152 # This software is Copyright (c) 2024 by Smithsonian Astrophysical Observatory.
153 #
154 # This is free software, licensed under:
155 #
156 # The GNU General Public License, Version 3, June 2007
157 #
158  
159 __END__
« blib/lib/CXC/Gnuplot/V1/Key.pm ↑ Summary blib/lib/CXC/Gnuplot/V1/Label.pm »