summaryrefslogtreecommitdiff
path: root/lib/WebService/TFL/TubeStatus/Response.pm
blob: b6b104be76a3522358b8a20a808be76eb75437b2 (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::TubeStatus::Response; 
use Moo;
use WebService::TFL::TubeStatus::Response::Line;
use Types::Standard -all;
use namespace::clean;
 
has lines => (
    is => 'ro',
    isa => ArrayRef[InstanceOf['WebService::TFL::TubeStatus::Response::Line']],
    required => 1,
);
 
sub new_from_response {
    my ($class,$response_data) = @_;
 
    return $class->new({
        lines=> [
            map { WebService::TFL::TubeStatus::Response::Line->new_from_response($_) }
            grep { $_->{'$type'} =~ /\bLine\b/ }
            $response_data->@*
        ],
    });
}
 
1;