summaryrefslogtreecommitdiff
path: root/lib/WebService/TFL/TubeStatus/Response.pm
blob: 191abe7cbb8975e1f2201afffeb68fe56885bce5 (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
26
27
28
29
30
package WebService::TFL::TubeStatus::Response; 
use Moo;
use WebService::TFL::TubeStatus::Types -all;
use WebService::TFL::TubeStatus::Response::Line;
use Types::Standard -all;
use namespace::autoclean;
 
has lines => (
    is => 'ro',
    isa => ArrayRef[LineT],
    required => 1,
);
 
sub new_from_xml {
    my ($class,$doc,$xpath) = @_;
 
    my @lines;
 
    for my $ls ($xpath->findnodes(q{/ws:ArrayOfLineStatus/ws:LineStatus},$doc)) {
        my ($line)=$xpath->findnodes(q{ws:Line},$ls);
 
        my $line_object = WebService::TFL::TubeStatus::Response::Line->new_from_xml($line,$ls,$xpath);
 
        push @lines,$line_object;
    }
 
    return $class->new({lines=>\@lines});
}
 
1;