lib/OpenSky/API/States.pm

filter: Statementstmt 76.9% 20 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod n/a totaltotal 78.1% 25 / 32 CC 1 SCAR 1.5
CC
1
Cov
77%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« lib/OpenSky/API/Core.pm ↑ Summary lib/OpenSky/API/Flights.pm »
1 # ,A class representing a states response from the OpenSky Network API
2  
3 package OpenSky::API::States;
4  
5 5 our $VERSION = '0.002';
6 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 use OpenSky::API::Types qw(
8 InstanceOf
9 PositiveOrZeroInt
10 5 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use OpenSky::API::Core::StateVector;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use OpenSky::API::Utils::Iterator;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use experimental qw(signatures);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 5 has time => ( is => 'ro', isa => PositiveOrZeroInt );
16 5 has vectors => (
17 is => 'ro',
18 isa => InstanceOf ['OpenSky::API::Utils::Iterator'],
19 handles => [qw(first next reset all count)],
20 );
21  
22 ▶around 'BUILDARGS' => sub ( $orig, $class, $response ) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 0 my $states = $response->{states};
24 0 my $time = $response->{time};
25  
26 0 my @state_vectors = map { OpenSky::API::Core::StateVector->new($_) } @$states;
27 0 my $iterator = OpenSky::API::Utils::Iterator->new( rows => \@state_vectors );
28  
29 0 return $class->$orig( vectors => $iterator, time => $time );
30 5 };
31  
32 5 __PACKAGE__->meta->make_immutable;
33  
34 __END__
35  
36 =pod
37  
38 =encoding UTF-8
39  
40 =head1 NAME
41  
42 OpenSky::API::States
43  
44 =head1 VERSION
45  
46 version 0.002
47  
48 =head1 METHODS
49  
50 =head2 time
51  
52 The time which the state vectors in this response are associated with. All
53 vectors represent the state of a vehicle with the interval C<[time=1, time]>.
54  
55 =head2 vectors
56  
57 Returns an iterator of L<OpenSky::API::Core::StateVector> objects.
58  
59 As a convenience, the following methods are delegated to the iterator:
60  
61 =over 4
62  
63 =item * first
64  
65 =item * next
66  
67 =item * reset
68  
69 =item * all
70  
71 =item * count
72  
73 =back
74  
75 =head1 AUTHOR
76  
77 Curtis "Ovid" Poe <curtis.poe@gmail.com>
78  
79 =head1 COPYRIGHT AND LICENSE
80  
81 This software is Copyright (c) 2023 by Curtis "Ovid" Poe.
82  
83 This is free software, licensed under:
84  
85 The Artistic License 2.0 (GPL Compatible)
86  
87 =cut
« lib/OpenSky/API/Core.pm ↑ Summary lib/OpenSky/API/Flights.pm »