blib/lib/Tags/HTML/GradientIndicator.pm

filter: Statementstmt 40.0% 14 / 35 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 57.1% 4 / 7 Podpod 100% 3 / 3 totaltotal 35.5% 21 / 59 CC 5 SCAR 26.6
CC
5
Cov
31%
new
30.0
process
2.0
process_css
2.0
CRAP 14.4
↑ Summary
1 package Tags::HTML::GradientIndicator;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Class::Utils qw(set_params);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 our $VERSION = 0.01;
10  
11 # Constructor.
12 sub new {
13 0 ▶ my ($class, @params) = @_;
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
14  
15 # Create object.
16 0 my $self = bless {}, $class;
17  
18 # 'CSS::Struct::Output' object.
19 0 $self->{'css'} = undef;
20  
21 # Gradient CSS class.
22 0 $self->{'css_gradient_class'} = 'gradient';
23  
24 # Height.
25 0 $self->{'height'} = 30;
26  
27 # Unit.
28 0 $self->{'unit'} = 'px';
29  
30 # Width.
31 0 $self->{'width'} = 500;
32  
33 # 'Tags::Output' object.
34 0 $self->{'tags'} = undef;
35  
36 # Process params.
37 0 set_params($self, @params);
38  
39 # Check to 'CSS::Struct::Output' object.
40 0 ▶ if ($self->{'css'} && ! $self->{'css'}->isa('CSS::Struct::Output')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"css"} and not $self->{"css"}->isa("CSS::Struct::Output")) 0 0 0
Condition0%0/3
$self->{"css"} and not $self->{"css"}->isa("CSS::Struct::Output")
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"css"} and not $self->{"css"}->isa("CSS::Struct::Output")
$self->{"css"} not $self->{"css"}->isa("CSS::Struct::Output")
Truth table0%0/3
A and not(B)
A= $self->{"css"}B= not $self->{"css"}->isa("CSS::Struct::Output")
ABresult
0X0
100
111
41 0 err "Parameter 'css' must be a 'CSS::Struct::Output::*' class.";
42 }
43  
44 # Check to 'Tags' object.
45 0 ▶ if (! $self->{'tags'} || ! $self->{'tags'}->isa('Tags::Output')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tags"} and $self->{"tags"}->isa("Tags::Output")) 0 0 0
Condition0%0/3
$self->{"tags"} and $self->{"tags"}->isa("Tags::Output")
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"tags"} and $self->{"tags"}->isa("Tags::Output")
$self->{"tags"} $self->{"tags"}->isa("Tags::Output")
Truth table0%0/3
A and B
A= $self->{"tags"}B= $self->{"tags"}->isa("Tags::Output")
ABresult
0X0
100
111
46 0 err "Parameter 'tags' must be a 'Tags::Output::*' class.";
47 }
48  
49 # Object.
50 0 return $self;
51 }
52  
53 # Process 'Tags'.
54 sub process {
55 0 ▶ my ($self, $percent_value) = @_;
Subroutine process: not called CC=1 SCAR=6.9
Pod documented
56  
57 # Value.
58 0 my $value = $percent_value * ($self->{'width'} / 100);
59  
60 # Main stars.
61 $self->{'tags'}->put(
62 ['b', 'div'],
63 ['a', 'style', 'width: '.$value.$self->{'unit'}.';overflow: hidden;'],
64  
65 ['b', 'div'],
66 0 ['a', 'class', $self->{'css_gradient_class'}],
67 ['e', 'div'],
68  
69 ['e', 'div'],
70 );
71  
72 0 return;
73 }
74  
75 # Process 'CSS::Struct'.
76 sub process_css {
77 0 ▶ my $self = shift;
Subroutine process_css: not called CC=1 SCAR=6.9
Pod documented
78  
79 $self->{'css'}->put(
80 ['s', '.'.$self->{'css_gradient_class'}],
81 ['d', 'height', $self->{'height'}.$self->{'unit'}],
82 0 ['d', 'width', $self->{'width'}.$self->{'unit'}],
83 ['d', 'background-color', 'red'],
84 ['d', 'background-image', 'linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet)'],
85 ['e'],
86 );
87  
88 0 return;
89 }
90  
91 2 1;
92  
93 __END__
↑ Summary