File Coverage

lib/WebService/OpenSky/Response/FlightTrack.pm
Criterion Covered Total %
statement 25 25 100.0
branch 5 10 50.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 35 41 85.3


line stmt bran cond sub pod time code
1             package WebService::OpenSky::Response::FlightTrack;
2              
3             # ABSTRACT: A class representing a flight track from the OpenSky Network API
4 8     8   75 use WebService::OpenSky::Moose;
  8         17  
  8         69  
5 8     8   131741 use WebService::OpenSky::Core::Waypoint;
  8         3652  
  8         2084  
6             extends 'WebService::OpenSky::Response';
7              
8             our $VERSION = '0.4';
9              
10             my @ATTRS = qw(
11             icao24
12             callsign
13             startTime
14             endTime
15             path
16             );
17              
18             # XXX ugly, but this is part of an experimental API endpoint from OpenSky
19             param [@ATTRS] => ( is => 'rw', required => 0 );
20              
21 2 50   2 0 56 method BUILD(@args) {
  2         4  
  2         10  
  2         4  
22 2         6 foreach my $attr (@ATTRS) {
23 10         156 $self->$attr( $self->raw_response->{$attr} );
24             }
25             }
26              
27 2 50   2   12 method _create_response_objects() {
  2 50       22  
  2         6  
  2         2  
28 2         7 my @path = map { WebService::OpenSky::Core::Waypoint->new($_) } $self->path->@*;
  20         20689  
29 2         1072 $self->path( \@path );
30 2         29 return \@path;
31             }
32              
33 1 50   1   6 method _empty_response() {
  1 50       3  
  1         3  
  1         2  
34 1         6 return { path => [] };
35             }
36              
37             __END__
38              
39             =pod
40              
41             =encoding UTF-8
42              
43             =head1 NAME
44              
45             WebService::OpenSky::Response::FlightTrack - A class representing a flight track from the OpenSky Network API
46              
47             =head1 VERSION
48              
49             version 0.4
50              
51             =head1 DESCRIPTION
52              
53             A set of "waypoints" for a given aircraft flight.
54              
55             This class inherits from L<WebService::OpenSky::Response>. Please see that
56             module for the available methods. Individual responses are from the
57             L<WebService::OpenSky::Core::Waypoint> class.
58              
59             =head1 ADDITIONAL ATTRIBUTES
60              
61             In addition to the methods and attributes provided by the parent class, this
62             class provides the following:
63              
64             =head2 C<icao24>
65              
66             The ICAO24 ID of the aircraft.
67              
68             =head2 C<callsign>
69              
70             The callsign of the aircraft. Can be C<undef>.
71              
72             =head2 C<startTime>
73              
74             The time of the first waypoint in seconds since epoch (Unix time).
75              
76             =head2 C<endTime>
77              
78             The time of the last waypoint in seconds since epoch (Unix time).
79              
80             =head2 C<waypoints>
81              
82             The waypoints of the flight. This is an arrayref of L<WebService::OpenSky::Core::Waypoint> objects.
83              
84             =head1 AUTHOR
85              
86             Curtis "Ovid" Poe <curtis.poe@gmail.com>
87              
88             =head1 COPYRIGHT AND LICENSE
89              
90             This software is Copyright (c) 2023 by Curtis "Ovid" Poe.
91              
92             This is free software, licensed under:
93              
94             The Artistic License 2.0 (GPL Compatible)
95              
96             =cut