blob: 0f811fc0d0338fe168d7975f83fff51559a82e27 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
package WebService::TFL::Bus::Response; use Moo; use Types::Standard -all; use WebService::TFL::Bus::Prediction; use namespace::clean; has predictions => ( is => 'ro', isa => ArrayRef[InstanceOf['WebService::TFL::Bus::Prediction']], ); sub new_from_response { my ($class,$response_data) = @_; return $class->new({ predictions => [ sort { $a->expectedArrival <=> $b->expectedArrival } map { WebService::TFL::Bus::Prediction->new_from_response($_) } grep { $_->{'$type'} =~ /\bPrediction\b/ } $response_data->@* ], }); } 1;
|