blib/lib/CXC/Gnuplot/V1/TerminalBase.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/Terminal/pngcairo.pm ↑ Summary blib/lib/CXC/Gnuplot/V0/Terminal/cairo.pm »
1 package CXC::Gnuplot::V1::TerminalBase;
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  
6 our $VERSION = 'v0.29.3';
7  
8 class CXC::Gnuplot::V1::TerminalBase : isa(CXC::Gnuplot::V1::Base)
9 does( CXC::Gnuplot::V1::Role::Clone );
10  
11 use experimental 'builtin', 'declared_refs';
12 use builtin::compat 'load_module', 'true';
13  
14 use CXC::Gnuplot::V1::Types -lexical => 'signature_for', 'SetFormats';
15 use CXC::Gnuplot::V1::Util -lexical => 'render_opts', 'render_set';
16  
17 my sub croak {
18 require Carp;
19 goto \&Carp::croak;
20 }
21  
22 ## no critic(Subroutines::ProtectPrivateSubs)
23 #<<< no tidy
24 field $size :param :reader //= q{};
25 field $ext :param :reader = __CLASS__->_DEFAULT_EXT;
26 #>>>
27  
28  
29  
30  
31  
32  
33  
34 # virtual class
35 ADJUST {
36 if ( __CLASS__ eq __PACKAGE__ ) {
37 require Carp;
38 Carp::croak( "can't instantiate @{[__CLASS__]}" );
39 }
40 }
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62 sub _DEFAULT_EXT ( $class ) {
63  
64 state %ext = (
65 cairolatex => '.tex',
66 canvas => '.js',
67 context => '.tex',
68 dxf => '.dxf',
69 emf => '.emf',
70 epscairo => '.eps',
71 epslatex => '.tex',
72 fig => '.fig',
73 gif => '.gif',
74 jpeg => '.jpg',
75 pbm => '.pbm',
76 pcl5 => '.pcl',
77 pdfcairo => '.pdf',
78 pict2e => '.tex',
79 pngcairo => '.png',
80 postscript => '.ps',
81 pslatex => '.tex',
82 pstricks => '.tex',
83 svg => '.svg',
84 texdraw => '.tex',
85 tikz => '.tex',
86 webp => '.webp',
87 );
88  
89 my ( $term ) = $class =~ /([^:]+)$/;
90 return $ext{$term} // q{};
91 }
92  
93  
94  
95  
96  
97  
98  
99  
100 method to_hash {
101 return {
102 ( defined $size ? ( size => $size ) : () ), #
103 ( defined $ext ? ( ext => $ext ) : () ),
104 };
105 }
106  
107  
108  
109  
110  
111  
112 method opts {
113 return $self->terminal, ( length( $size ) ? [ size => $size ] : () );
114 }
115  
116  
117  
118  
119  
120 signature_for set => (
121 method => 1,
122 named => [
123 as => SetFormats,
124 { default => 'string' },
125 ],
126 );
127  
128 method set ( $opt ) {
129 return render_set( [ render_opts( [ set => 'terminal' ], $self ) ], $opt->as );
130 }
131  
132 1;
133  
134 #
135 # This file is part of CXC-Gnuplot
136 #
137 # This software is Copyright (c) 2024 by Smithsonian Astrophysical Observatory.
138 #
139 # This is free software, licensed under:
140 #
141 # The GNU General Public License, Version 3, June 2007
142 #
143  
144 __END__
« blib/lib/CXC/Gnuplot/V1/Terminal/pngcairo.pm ↑ Summary blib/lib/CXC/Gnuplot/V0/Terminal/cairo.pm »