Com/DayPart.pm

filter: Statementstmt 29.2% 19 / 65 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 42.8% 6 / 14 Podpod 75.0% 6 / 8 totaltotal 31.0% 31 / 100 CC 6 SCAR 19.5
CC
6
Cov
25%
update
20.0
new
12.0
type
2.0
CRAP 7.1
« Com/Location.pm ↑ Summary Com/UVIndex.pm »
1 package Weather::Com::DayPart;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Weather::Com::L10N;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Weather::Com::Wind;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use base 'Weather::Com::Object';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = sprintf "%d.%03d", q$Revision: 1.8 $ =~ /(\d+)/g;
11  
12 #------------------------------------------------------------------------
13 # Constructor
14 #------------------------------------------------------------------------
15 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
16 0 my $proto = shift;
17 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
18 0 my %parameters;
19  
20 # parameters provided by new method
21 0 ▶ if ( ref( $_[0] ) eq "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
22 0 %parameters = %{ $_[0] };
23 } else {
24 0 %parameters = @_;
25 }
26  
27 0 my $self = $class->SUPER::new( \%parameters );
28  
29 # getting first weather information
30 0 $self->{TYPE} = undef;
31 0 $self->{CONDITIONS} = 'N/A';
32 0 $self->{HUMIDITY} = 'N/A';
33 0 $self->{ICON} = undef;
34 0 $self->{PRECIPITATION} = undef;
35 0 $self->{WIND} = undef;
36  
37 0 return $self;
38 } # end new()
39  
40 #------------------------------------------------------------------------
41 # update data
42 #------------------------------------------------------------------------
43 0 ▶sub update {
Subroutine update: not called CC=4 SCAR=30.0
Pod undocumented
44 0 my $self = shift;
45 0 my %daypart;
46  
47 0 ▶ if ( ref( $_[0] ) eq "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
48 0 %daypart = %{ $_[0] };
49 } else {
50 0 %daypart = @_;
51 }
52  
53 0 ▶ if ( $daypart{p} eq "d" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($daypart{'p'} eq 'd') { } 0 0 0
54 0 $self->{TYPE} = "day";
55 } else {
56 0 $self->{TYPE} = "night";
57 }
58  
59 0 $self->{CONDITIONS} = $daypart{t};
60 0 $self->{HUMIDITY} = $daypart{hmid};
61 0 $self->{ICON} = $daypart{icon};
62 0 $self->{PRECIPITATION} = $daypart{ppcp};
63  
64 0 ▶ unless ( $self->{WIND} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"WIND"}) 0 0 0
65 0 $self->{WIND} = Weather::Com::Wind->new( $self->{ARGS} );
66 }
67  
68 0 $self->wind()->update( $daypart{wind} );
69  
70 0 return 1;
71 }
72  
73 #------------------------------------------------------------------------
74 # access data
75 #------------------------------------------------------------------------
76 0 ▶sub type {
Subroutine type: not called CC=1 SCAR=6.9
Pod documented
77 0 my $self = shift;
78 0 my $language = shift;
79 0 return $self->get_language_handle($language)->maketext( $self->{TYPE} );
80 }
81  
82 0 ▶sub conditions {
Subroutine conditions: not called CC=1 SCAR=6.9
Pod documented
83 0 my $self = shift;
84 0 my $language = shift;
85 return $self->get_language_handle($language)
86 0 ->maketext( lc( $self->{CONDITIONS} ) );
87 }
88  
89 0 ▶sub humidity {
Subroutine humidity: not called CC=1 SCAR=6.9
Pod documented
90 0 my $self = shift;
91 0 return $self->{HUMIDITY};
92 }
93  
94 0 ▶sub icon {
Subroutine icon: not called CC=1 SCAR=6.9
Pod documented
95 0 my $self = shift;
96 0 return $self->{ICON};
97 }
98  
99 0 ▶sub precipitation {
Subroutine precipitation: not called CC=1 SCAR=6.9
Pod documented
100 0 my $self = shift;
101 0 return $self->{PRECIPITATION};
102 }
103  
104 0 ▶sub wind {
Subroutine wind: not called CC=1 SCAR=6.9
Pod documented
105 0 my $self = shift;
106 0 return $self->{WIND};
107 }
108  
109 1 1;
110  
111 __END__
« Com/Location.pm ↑ Summary Com/UVIndex.pm »