OpenWeatherMap/Result/Forecast/Block.pm

filter: Statementstmt 92.3% 36 / 39 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 80.0% 12 / 15 Podpod n/a totaltotal 80.0% 52 / 65 CC 6 SCAR 5.1
CC
6
Cov
85%
_build__first_weather_item
2.1
_build_conditions_terse
2.1
_build_conditions_verbose
2.1
CRAP 1.7
« OpenWeatherMap/Request.pm ↑ Summary OpenWeatherMap/Result/Forecast/Hour.pm »
1 package Weather::OpenWeatherMap::Result::Forecast::Block;
2 2 $Weather::OpenWeatherMap::Result::Forecast::Block::VERSION = '0.003001';
3 2 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Types::Standard -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Types::DateTime -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use List::Objects::Types -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Weather::OpenWeatherMap::Units -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 2 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use Storable 'freeze';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 requires qw/
17 cloud_coverage
18 humidity
19 pressure
20 wind_speed_mph
21 wind_speed_kph
22 wind_direction
23 wind_direction_degrees
24 /;
25  
26 has dt => (
27 is => 'ro',
28 isa => DateTimeUTC,
29 coerce => 1,
30 0 ▶ builder => sub { 0 },
Subroutine _build_dt: not called CC=1 SCAR=6.9
31 2 );
32  
33 has _weather_list => (
34 init_arg => 'weather',
35 is => 'ro',
36 isa => ArrayObj,
37 coerce => 1,
38 0 ▶ builder => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine _build__weather_list: not called CC=1 SCAR=6.9
39 2 );
40  
41 has _first_weather_item => (
42 lazy => 1,
43 is => 'ro',
44 isa => HashRef,
45 5 ▶ builder => sub { shift->_weather_list->[0] || +{} },
Subroutine _build__first_weather_item: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->_weather_list->[0] or {} 0 5 5
46 2 );
47  
48  
49 has conditions_terse => (
50 lazy => 1,
51 is => 'ro',
52 isa => Str,
53 5 ▶ builder => sub { shift->_first_weather_item->{main} // '' },
Subroutine _build_conditions_terse: called CC=2 SCAR=7.6
Condition50%1/2
+(shift())->_first_weather_item->{"main"} // ""
l!l
50
MC/DC0%0/1
+(shift())->_first_weather_item->{"main"} // ""
+(shift())->_first_weather_item->{"main"}
Truth table50%1/2
A
A= +(shift())->_first_weather_item->{"main"}
Aresult
11
00
54 2 );
55  
56 has conditions_verbose => (
57 lazy => 1,
58 is => 'ro',
59 isa => Str,
60 5 ▶ builder => sub { shift->_first_weather_item->{description} // '' },
Subroutine _build_conditions_verbose: called CC=2 SCAR=7.6
Condition50%1/2
+(shift())->_first_weather_item->{"description"} // ""
l!l
50
MC/DC0%0/1
+(shift())->_first_weather_item->{"description"} // ""
+(shift())->_first_weather_item->{"description"}
Truth table50%1/2
A
A= +(shift())->_first_weather_item->{"description"}
Aresult
11
00
61 2 );
62  
63 has conditions_code => (
64 lazy => 1,
65 is => 'ro',
66 isa => Int,
67 5 ▶ builder => sub { shift->_first_weather_item->{id} // 0 },
Subroutine __ANON__: called CC=2 SCAR=7.6
Condition50%1/2
+(shift())->_first_weather_item->{"id"} // 0
l!l
50
MC/DC0%0/1
+(shift())->_first_weather_item->{"id"} // 0
+(shift())->_first_weather_item->{"id"}
Truth table50%1/2
A
A= +(shift())->_first_weather_item->{"id"}
Aresult
11
00
68 2 );
69  
70 has conditions_icon => (
71 lazy => 1,
72 is => 'ro',
73 isa => Maybe[Str],
74 5 ▶ builder => sub { shift->_first_weather_item->{icon} },
Subroutine _build_conditions_icon: called CC=1 SCAR=0.0
75 2 );
76  
77 2 1;
78  
79 =pod
80  
81 =head1 NAME
82  
83 Weather::OpenWeatherMap::Result::Forecast::Block - A Role for weather forecast items
84  
85 =head1 SYNOPSIS
86  
87 # A Role providing attributes/methods for objects produced by a
88 # Weather::OpenWeatherMap::Result::Forecast, one of:
89 # Weather::OpenWeatherMap::Result::Forecast::Day
90 # Weather::OpenWeatherMap::Result::Forecast::Hour
91  
92 =head1 DESCRIPTION
93  
94 This role provides methods and attributes for classes implementing a
95 L<Weather::OpenWeatherMap> weather forecast for a block of time, such as
96 L<Weather::OpenWeatherMap::Result::Forecast::Day> &
97 L<Weather::OpenWeatherMap::Result::Forecast::Hour>.
98  
99 =head2 ATTRIBUTES
100  
101 =head3 cloud_coverage
102  
103 The forecast cloud coverage as a percentage.
104  
105 =head3 conditions_terse
106  
107 The conditions category.
108  
109 =head3 conditions_verbose
110  
111 The conditions description string.
112  
113 =head3 conditions_code
114  
115 The L<OpenWeatherMap|http://www.openweathermap.org/> conditions code.
116  
117 =head3 conditions_icon
118  
119 The L<OpenWeatherMap|http://www.openweathermap.org/> conditions icon.
120  
121 =head3 dt
122  
123 my $date = $result->dt->mdy;
124  
125 A L<DateTime> object coerced from the timestamp (in UTC) attached to this
126 forecast.
127  
128 =head3 humidity
129  
130 The forecast humidity as a percentage.
131  
132 =head3 pressure
133  
134 The forecast atmospheric pressure in hPa.
135  
136 =head3 wind_speed_mph
137  
138 The forecast wind speed in MPH.
139  
140 =head3 wind_speed_kph
141  
142 The forecast wind speed in KPH.
143  
144 =head3 wind_direction
145  
146 The forecast wind direction as a (inter-)cardinal direction in the set
147 C<< [ N NNE NE ENE E ESE SE SSE S SSW SW WSW W WNW NW NNW ] >>
148  
149 =head3 wind_direction_degrees
150  
151 The forecast wind direction in degrees azimuth.
152  
153 =head1 SEE ALSO
154  
155 L<Weather::OpenWeatherMap::Result>
156  
157 L<Weather::OpenWeatherMap::Result::Forecast>
158  
159 L<Weather::OpenWeatherMap::Result::Forecast::Day>
160  
161 L<Weather::OpenWeatherMap::Result::Forecast::Hour>
162  
163 L<Weather::OpenWeatherMap::Result::Current>
164  
165 L<http://www.openweathermap.org>
166  
167 =head1 AUTHOR
168  
169 Jon Portnoy <avenj@cobaltirc.org>
170  
171 =cut
« OpenWeatherMap/Request.pm ↑ Summary OpenWeatherMap/Result/Forecast/Hour.pm »