| 1 | package Weather::OpenWeatherMap::Result::Forecast::Block; | ||||||||||||
| 2 | 1 | $Weather::OpenWeatherMap::Result::Forecast::Block::VERSION = '0.005001'; | |||||||||||
| 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 | 1 | 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 | 1 | ); | |||||||||||
| 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
| |||||||||||||
| 39 | 1 | ); | |||||||||||
| 40 | |||||||||||||
| 41 | has _first_weather_item => ( | ||||||||||||
| 42 | lazy => 1, | ||||||||||||
| 43 | is => 'ro', | ||||||||||||
| 44 | isa => HashRef, | ||||||||||||
| 45 | 8 | ▶ | builder => sub { shift->_weather_list->[0] || +{} }, | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||
| 46 | 1 | ); | |||||||||||
| 47 | |||||||||||||
| 48 | |||||||||||||
| 49 | has conditions_terse => ( | ||||||||||||
| 50 | lazy => 1, | ||||||||||||
| 51 | is => 'ro', | ||||||||||||
| 52 | isa => Str, | ||||||||||||
| 53 | 8 | ▶ | builder => sub { shift->_first_weather_item->{main} // '' }, | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Condition50%1/2
+(shift())->_first_weather_item->{"main"} // ""
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"}
| |||||||||||||
| 54 | 1 | ); | |||||||||||
| 55 | |||||||||||||
| 56 | has conditions_verbose => ( | ||||||||||||
| 57 | lazy => 1, | ||||||||||||
| 58 | is => 'ro', | ||||||||||||
| 59 | isa => Str, | ||||||||||||
| 60 | 8 | ▶ | 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"} // ""
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"}
| |||||||||||||
| 61 | 1 | ); | |||||||||||
| 62 | |||||||||||||
| 63 | has conditions_code => ( | ||||||||||||
| 64 | lazy => 1, | ||||||||||||
| 65 | is => 'ro', | ||||||||||||
| 66 | isa => Int, | ||||||||||||
| 67 | 8 | ▶ | 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
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"}
| |||||||||||||
| 68 | 1 | ); | |||||||||||
| 69 | |||||||||||||
| 70 | has conditions_icon => ( | ||||||||||||
| 71 | lazy => 1, | ||||||||||||
| 72 | is => 'ro', | ||||||||||||
| 73 | isa => Maybe[Str], | ||||||||||||
| 74 | 6 | ▶ | builder => sub { shift->_first_weather_item->{icon} }, | ||||||||||
|
Subroutine
_build_conditions_icon: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 75 | 1 | ); | |||||||||||
| 76 | |||||||||||||
| 77 | 1 | 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 | ||||||||||||