OpenWeatherMap/Result/Find.pm

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