| 1 | # ,A class representing a states response from the OpenSky Network API | ||
| 2 | |||
| 3 | package OpenSky::API::States; | ||
| 4 | |||
| 5 | 5 | our $VERSION = '0.005'; | |
| 6 | 5 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 5 | ▶ | use OpenSky::API::Types qw( |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | InstanceOf | ||
| 9 | PositiveOrZeroInt | ||
| 10 | 5 | ); | |
| 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 | 0 | ▶ | 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__ | ||