Com/DayForecast.pm

filter: Statementstmt 27.8% 22 / 79 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 43.7% 7 / 16 Podpod 77.7% 7 / 9 totaltotal 28.8% 36 / 125 CC 11 SCAR 35.1
CC
11
Cov
22%
update
90.0
new
12.0
date
2.0
CRAP 33.3
« Com/Simple.pm ↑ Summary Com/Finder.pm »
1 package Weather::Com::DayForecast;
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 warnings;
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::DayPart;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Weather::Com::DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use base 'Weather::Com::Object';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our $VERSION = sprintf "%d.%03d", q$Revision: 1.8 $ =~ /(\d+)/g;
12  
13 #------------------------------------------------------------------------
14 # Constructor
15 #------------------------------------------------------------------------
16 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
17 0 my $proto = shift;
18 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
19 0 my %parameters;
20  
21 # parameters provided by new method
22 0 ▶ if ( ref( $_[0] ) eq "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
23 0 %parameters = %{ $_[0] };
24 } else {
25 0 %parameters = @_;
26 }
27  
28 0 my $self = $class->SUPER::new( \%parameters );
29  
30 # getting first weather information
31 0 $self->{DATE} = undef;
32 0 $self->{HIGH} = 'N/A';
33 0 $self->{LOW} = 'N/A';
34 0 $self->{SUNRISE} = undef;
35 0 $self->{SUNSET} = undef;
36 0 $self->{DAY} = undef;
37 0 $self->{NIGHT} = undef;
38  
39 0 return $self;
40 } # end new()
41  
42 #------------------------------------------------------------------------
43 # update data
44 #------------------------------------------------------------------------
45 0 ▶sub update {
Subroutine update: not called CC=9 SCAR=45.0
Pod undocumented
46 0 my $self = shift;
47 0 my %day;
48  
49 0 ▶ if ( ref( $_[0] ) eq "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
50 0 %day = %{ $_[0] };
51 } else {
52 0 %day = @_;
53 }
54  
55 # update date and time data
56 0 ▶ unless ( $self->date() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->date) 0 0 0
57 0 $self->{DATE} = Weather::Com::DateTime->new( $day{zone} );
58 0 $self->{SUNRISE} = Weather::Com::DateTime->new( $day{zone} );
59 0 $self->{SUNSET} = Weather::Com::DateTime->new( $day{zone} );
60 }
61  
62 0 $self->date()->set_date( $day{dt} );
63 0 $self->sunrise()->set_time( $day{sunr} );
64 0 $self->sunset()->set_time( $day{suns} );
65  
66 # update weather data
67 # if $day{hi} eq "N/A" then there is no daytime forecast
68 0 ▶ unless ( $day{hi} eq 'N/A' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($day{'hi'} eq 'N/A') { } 0 0 0
69 0 $self->{HIGH} = $day{hi};
70 } else {
71 0 $self->{HIGH} = 'N/A';
72 }
73 0 $self->{LOW} = $day{low};
74  
75 0 foreach my $daypart ( @{ $day{part} } ) {
76 0 ▶ if ( $daypart->{p} eq 'd' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($daypart->{'p'} eq 'd') { } 0 0 0
77  
78 # if $day{hi} eq "N/A" then there is no daytime forecast
79 0 ▶ if ( $day{hi} ne 'N/A' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($day{"hi"} ne "N/A") 0 0 0
80 0 ▶ unless ( $self->{DAY} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"DAY"}) 0 0 0
81 0 $self->{DAY} = Weather::Com::DayPart->new( $self->{ARGS} );
82 }
83 0 $self->day()->update($daypart);
84 }
85 } else {
86 0 ▶ unless ( $self->{NIGHT} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"NIGHT"}) 0 0 0
87 0 $self->{NIGHT} = Weather::Com::DayPart->new( $self->{ARGS} );
88 }
89 0 $self->night()->update($daypart);
90 }
91 }
92 }
93  
94 #------------------------------------------------------------------------
95 # access data
96 #------------------------------------------------------------------------
97 0 ▶sub date {
Subroutine date: not called CC=1 SCAR=6.9
Pod documented
98 0 my $self = shift;
99 0 return $self->{DATE};
100 }
101  
102 0 ▶sub high {
Subroutine high: not called CC=1 SCAR=6.9
Pod documented
103 0 my $self = shift;
104 0 return $self->{HIGH};
105 }
106  
107 0 ▶sub low {
Subroutine low: not called CC=1 SCAR=6.9
Pod documented
108 0 my $self = shift;
109 0 return $self->{LOW};
110 }
111  
112 0 ▶sub sunrise {
Subroutine sunrise: not called CC=1 SCAR=6.9
Pod documented
113 0 my $self = shift;
114 0 return $self->{SUNRISE};
115 }
116  
117 0 ▶sub sunset {
Subroutine sunset: not called CC=1 SCAR=6.9
Pod documented
118 0 my $self = shift;
119 0 return $self->{SUNSET};
120 }
121  
122 0 ▶sub day {
Subroutine day: not called CC=1 SCAR=6.9
Pod documented
123 0 my $self = shift;
124 0 return $self->{DAY};
125 }
126  
127 0 ▶sub night {
Subroutine night: not called CC=1 SCAR=6.9
Pod documented
128 0 my $self = shift;
129 0 return $self->{NIGHT};
130 }
131  
132 1 1;
133  
134 __END__
« Com/Simple.pm ↑ Summary Com/Finder.pm »