| 1 | package Weather::OpenWeatherMap::Result::Find; | ||||||||||||||||||||||
| 2 | 2 | $Weather::OpenWeatherMap::Result::Find::VERSION = '0.005001'; | |||||||||||||||||||||
| 3 | 2 | ▶ | use Carp; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | 2 | ▶ | use strictures 2; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 5 | |||||||||||||||||||||||
| 6 | 2 | ▶ | use List::Objects::WithUtils; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 7 | 2 | ▶ | use Types::Standard -all; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 8 | 2 | ▶ | use List::Objects::Types -all; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 9 | |||||||||||||||||||||||
| 10 | 2 | ▶ | use Weather::OpenWeatherMap::Result::Current; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 11 | |||||||||||||||||||||||
| 12 | |||||||||||||||||||||||
| 13 | 2 | ▶ | use Moo; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 14 | 2 | extends 'Weather::OpenWeatherMap::Result'; | |||||||||||||||||||||
| 15 | |||||||||||||||||||||||
| 16 | |||||||||||||||||||||||
| 17 | has message => ( | ||||||||||||||||||||||
| 18 | lazy => 1, | ||||||||||||||||||||||
| 19 | is => 'ro', | ||||||||||||||||||||||
| 20 | isa => Str, | ||||||||||||||||||||||
| 21 | 2 | ▶ | builder => sub { shift->data->{message} // '' }, | ||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Subroutine
_build_message: called CC=2 SCAR=7.6
Condition50%2/4
+(shift())->data->{"message"} // ""
+(shift())->data->{"message"} // ""
MC/DC0%0/1
+(shift())->data->{"message"} // ""
+(shift())->data->{"message"}
MC/DC0%0/1
+(shift())->data->{"message"} // ""
+(shift())->data->{"message"}
Truth table50%1/2
A
A= +(shift())->data->{"message"}
Truth table50%1/2
A
A= +(shift())->data->{"message"}
| |||||||||||||||||||||||
| 22 | 2 | ); | |||||||||||||||||||||
| 23 | 3 | ▶ | sub search_type { shift->message } | ||||||||||||||||||||
|
Subroutine
search_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 24 | |||||||||||||||||||||||
| 25 | |||||||||||||||||||||||
| 26 | has _list => ( | ||||||||||||||||||||||
| 27 | init_arg => 'list', | ||||||||||||||||||||||
| 28 | lazy => 1, | ||||||||||||||||||||||
| 29 | is => 'ro', | ||||||||||||||||||||||
| 30 | isa => TypedArray[ | ||||||||||||||||||||||
| 31 | InstanceOf['Weather::OpenWeatherMap::Result::Current'] | ||||||||||||||||||||||
| 32 | ], | ||||||||||||||||||||||
| 33 | coerce => 1, | ||||||||||||||||||||||
| 34 | builder => sub { | ||||||||||||||||||||||
| 35 | 3 | ▶ | my ($self) = @_; | ||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||
| 36 | 3 | ▶ | my @list = @{ $self->data->{list} || [] }; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 37 | [ | ||||||||||||||||||||||
| 38 | 3 | map {; | |||||||||||||||||||||
| 39 | 6 | Weather::OpenWeatherMap::Result::Current->new( | |||||||||||||||||||||
| 40 | request => $self->request, | ||||||||||||||||||||||
| 41 | json => $self->encode_json($_), | ||||||||||||||||||||||
| 42 | data => +{%$_}, | ||||||||||||||||||||||
| 43 | ) | ||||||||||||||||||||||
| 44 | } @list | ||||||||||||||||||||||
| 45 | ] | ||||||||||||||||||||||
| 46 | }, | ||||||||||||||||||||||
| 47 | 2 | ); | |||||||||||||||||||||
| 48 | |||||||||||||||||||||||
| 49 | 3 | ▶ | sub count { shift->_list->count } | ||||||||||||||||||||
|
Subroutine
count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 50 | 6 | ▶ | sub list { shift->_list->all } | ||||||||||||||||||||
|
Subroutine
list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 51 | 3 | ▶ | sub as_array { array(shift->_list->all) } | ||||||||||||||||||||
|
Subroutine
as_array: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||
| 52 | sub iter { | ||||||||||||||||||||||
| 53 | 6 | ▶ | my ($self, $count) = @_; | ||||||||||||||||||||
|
Subroutine
iter: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 54 | 6 | ▶ | $self->_list->natatime($count || 1) | ||||||||||||||||||||
|
Condition100%2/2
$count || 1
MC/DC100%1/1
$count || 1
$count
Truth table100%2/2
A
A= $count
| |||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||
| 56 | |||||||||||||||||||||||
| 57 | |||||||||||||||||||||||
| 58 | 2 | 1; | |||||||||||||||||||||
| 59 | |||||||||||||||||||||||
| 60 | =pod | ||||||||||||||||||||||
| 61 | |||||||||||||||||||||||
| 62 | =head1 NAME | ||||||||||||||||||||||
| 63 | |||||||||||||||||||||||
| 64 | Weather::OpenWeatherMap::Result::Find - Location search result | ||||||||||||||||||||||
| 65 | |||||||||||||||||||||||
| 66 | =head1 SYNOPSIS | ||||||||||||||||||||||
| 67 | |||||||||||||||||||||||
| 68 | # Normally retrieved via Weather::OpenWeatherMap | ||||||||||||||||||||||
| 69 | |||||||||||||||||||||||
| 70 | =head1 DESCRIPTION | ||||||||||||||||||||||
| 71 | |||||||||||||||||||||||
| 72 | This is a subclass of L<Weather::OpenWeatherMap::Result> containing the result | ||||||||||||||||||||||
| 73 | of a completed L<Weather::OpenWeatherMap::Request::Find>. | ||||||||||||||||||||||
| 74 | |||||||||||||||||||||||
| 75 | These are normally returned by a L<Weather::OpenWeatherMap> instance (or | ||||||||||||||||||||||
| 76 | emitted by L<POEx::Weather::OpenWeatherMap>. | ||||||||||||||||||||||
| 77 | |||||||||||||||||||||||
| 78 | =head2 ATTRIBUTES | ||||||||||||||||||||||
| 79 | |||||||||||||||||||||||
| 80 | =head3 message | ||||||||||||||||||||||
| 81 | |||||||||||||||||||||||
| 82 | The message from the OpenWeatherMap backend indicating the type of search | ||||||||||||||||||||||
| 83 | completed (C<accurate> or C<like>). | ||||||||||||||||||||||
| 84 | |||||||||||||||||||||||
| 85 | =head2 METHODS | ||||||||||||||||||||||
| 86 | |||||||||||||||||||||||
| 87 | =head3 as_array | ||||||||||||||||||||||
| 88 | |||||||||||||||||||||||
| 89 | The full result list, as a L<List::Objects::WithUtils::Array>. | ||||||||||||||||||||||
| 90 | |||||||||||||||||||||||
| 91 | See L</list>. | ||||||||||||||||||||||
| 92 | |||||||||||||||||||||||
| 93 | =head3 count | ||||||||||||||||||||||
| 94 | |||||||||||||||||||||||
| 95 | Returns the number of items available in the current result L</list>. | ||||||||||||||||||||||
| 96 | |||||||||||||||||||||||
| 97 | =head3 list | ||||||||||||||||||||||
| 98 | |||||||||||||||||||||||
| 99 | The full result list; each item in the list is a | ||||||||||||||||||||||
| 100 | L<Weather::OpenWeatherMap::Result::Current> instance: | ||||||||||||||||||||||
| 101 | |||||||||||||||||||||||
| 102 | for my $place ($result->list) { | ||||||||||||||||||||||
| 103 | my $region = $place->country; | ||||||||||||||||||||||
| 104 | my $tempf = $place->temp_f; | ||||||||||||||||||||||
| 105 | # ... | ||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||
| 107 | |||||||||||||||||||||||
| 108 | See L<Weather::OpenWeatherMap::Result::Current>. | ||||||||||||||||||||||
| 109 | |||||||||||||||||||||||
| 110 | The current weather returned by a Find is not quite as complete as that | ||||||||||||||||||||||
| 111 | returned by an actual L<Weather::OpenWeatherMap::Request::Current>. In | ||||||||||||||||||||||
| 112 | particular: | ||||||||||||||||||||||
| 113 | |||||||||||||||||||||||
| 114 | =over | ||||||||||||||||||||||
| 115 | |||||||||||||||||||||||
| 116 | =item * | ||||||||||||||||||||||
| 117 | |||||||||||||||||||||||
| 118 | The B<country> attribute is likely to be a two-letter region identifier, not a | ||||||||||||||||||||||
| 119 | full country name. | ||||||||||||||||||||||
| 120 | |||||||||||||||||||||||
| 121 | =item * | ||||||||||||||||||||||
| 122 | |||||||||||||||||||||||
| 123 | The B<sunrise> and B<sunset> attributes are unavailable. | ||||||||||||||||||||||
| 124 | |||||||||||||||||||||||
| 125 | =item * | ||||||||||||||||||||||
| 126 | |||||||||||||||||||||||
| 127 | Wind gust speed may be unavailable. | ||||||||||||||||||||||
| 128 | |||||||||||||||||||||||
| 129 | =item * | ||||||||||||||||||||||
| 130 | |||||||||||||||||||||||
| 131 | The B<station> name is unavailable. | ||||||||||||||||||||||
| 132 | |||||||||||||||||||||||
| 133 | =back | ||||||||||||||||||||||
| 134 | |||||||||||||||||||||||
| 135 | =head3 iter | ||||||||||||||||||||||
| 136 | |||||||||||||||||||||||
| 137 | Returns an iterator that, when called, returns the next | ||||||||||||||||||||||
| 138 | L<Weather::OpenWeatherMap::Result::Current> instance (or undef when the list | ||||||||||||||||||||||
| 139 | is empty): | ||||||||||||||||||||||
| 140 | |||||||||||||||||||||||
| 141 | my $iter = $result->iter; | ||||||||||||||||||||||
| 142 | while (my $place = $iter->()) { | ||||||||||||||||||||||
| 143 | my $region = $place->country; | ||||||||||||||||||||||
| 144 | # ... | ||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||
| 146 | |||||||||||||||||||||||
| 147 | =head3 search_type | ||||||||||||||||||||||
| 148 | |||||||||||||||||||||||
| 149 | An alias for L</message>. | ||||||||||||||||||||||
| 150 | |||||||||||||||||||||||
| 151 | =head1 AUTHOR | ||||||||||||||||||||||
| 152 | |||||||||||||||||||||||
| 153 | Jon Portnoy <avenj@cobaltirc.org> | ||||||||||||||||||||||
| 154 | |||||||||||||||||||||||
| 155 | =cut | ||||||||||||||||||||||