diff options
Diffstat (limited to 'lib/WebService/TFL/TubeStatus/Response.pm')
-rw-r--r-- | lib/WebService/TFL/TubeStatus/Response.pm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/WebService/TFL/TubeStatus/Response.pm b/lib/WebService/TFL/TubeStatus/Response.pm new file mode 100644 index 0000000..f8cd8bf --- /dev/null +++ b/lib/WebService/TFL/TubeStatus/Response.pm @@ -0,0 +1,28 @@ +package WebService::TFL::TubeStatus::Response; +use Moose; +use WebService::TFL::TubeStatus::Response::Line; +use namespace::autoclean; + +has lines => ( + is => 'ro', + isa => 'ArrayRef[WebService::TFL::TubeStatus::Response::Line]', + 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; |