OpenGbg/Service/TrafficCamera/CameraDevices.pm

filter: Statementstmt 80.0% 16 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 100% 1 / 1 totaltotal 77.7% 21 / 27 CC 1 SCAR 2.9
CC
1
Cov
80%
get_by_id
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.3
« OpenGbg.pm ↑ Summary OpenGbg/Service/Bridge.pm »
1 1 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package OpenGbg::Service::TrafficCamera::CameraDevices;
6  
7 # ABSTRACT: A list of traffic cameras
8 1 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 1 our $VERSION = '0.1401';
10  
11 1 ▶use XML::Rabbit;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 has_xpath_object_list _camera_devices => './x:CameraDevice' => 'OpenGbg::Service::TrafficCamera::CameraDevice',
14 handles => {
15 all => 'elements',
16 count => 'count',
17 filter => 'grep',
18 find => 'first',
19 get_by_index => 'get',
20 map => 'map',
21 sort => 'sort',
22 };
23  
24 sub get_by_id {
25 0 ▶ my $self = shift;
Subroutine get_by_id: not called CC=1 SCAR=6.9
Pod documented
26 0 my $id = shift;
27 0 ▶ return $self->find(sub { $_ == $id });
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 }
29  
30 1 finalize_class();
31  
32 1 1;
33  
34 __END__
35  
36 =pod
37  
38 =encoding utf-8
39  
40 =head1 NAME
41  
42 OpenGbg::Service::TrafficCamera::CameraDevices - A list of traffic cameras
43  
44 =head1 VERSION
45  
46 Version 0.1401, released 2016-05-05.
47  
48 =head1 SYNOPSIS
49  
50 my $traffic_camera_service = OpenGbg->new->traffic_camera;
51 my $get_traffic_cameras = $traffic_camera_service->get_traffic_cameras;
52  
53 my $camera_devices = $get_traffic_cameras->camera_devices;
54 print $camera_devices->get_by_index(0)->to_text;
55  
56 =head1 METHODS
57  
58 =head2 all
59  
60 Returns an array of all L<OpenGbg::Service::TrafficCamera::CameraDevice> objects in the response.
61  
62 =head2 count
63  
64 Returns the number of L<CameraDevice|OpenGbg::Service::TrafficCamera::CameraDevice> objects in the response.
65  
66 =head2 filter(sub { ... })
67  
68 Allows filtering of the traffic cameras. Takes a sub routine reference, into which all L<CameraDevice|OpenGbg::Service::TrafficCamera::CameraDevice> objects are
69 passed one-by-one into C<$_>. Works like C<grep>.
70  
71 =head2 find(sub { ... })
72  
73 Just like C<filter>, except it returns the first traffic camera that matches.
74  
75 =head2 get_by_index($index)
76  
77 Returns the n:th L<OpenGbg::Service::TrafficCamera::CameraDevice> object in the response.
78  
79 =head2 get_by_id($id)
80  
81 Returns the traffic camera with id C<$id>.
82  
83 =head2 map(sub { ... })
84  
85 Like C<filter> it takes a sub routine reference and passes each L<CameraDevice|OpenGbg::Service::TrafficCamera::CameraDevice> as C<$_>. Eg, to get a total count of free bikes:
86  
87 =head2 sort(sub { ... })
88  
89 Like C<filter> it takes a sub routine reference. It works just like C<sort> except the two L<CameraDevice|OpenGbg::Service::TrafficCamera::CameraDevice> objects to compare are passed as C<$_[0]> and C<$_[1]>
90  
91 =head1 SOURCE
92  
93 L<https://github.com/Csson/p5-OpenGbg>
94  
95 =head1 HOMEPAGE
96  
97 L<https://metacpan.org/release/OpenGbg>
98  
99 =head1 AUTHOR
100  
101 Erik Carlsson <info@code301.com>
102  
103 =head1 COPYRIGHT AND LICENSE
104  
105 This software is copyright (c) 2016 by Erik Carlsson.
106  
107 This is free software; you can redistribute it and/or modify it under
108 the same terms as the Perl 5 programming language system itself.
109  
110 =cut
« OpenGbg.pm ↑ Summary OpenGbg/Service/Bridge.pm »