summaryrefslogtreecommitdiff
path: root/lib/WebService/TFL/TubeStatus/Response.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/WebService/TFL/TubeStatus/Response.pm')
-rw-r--r--lib/WebService/TFL/TubeStatus/Response.pm27
1 files changed, 11 insertions, 16 deletions
diff --git a/lib/WebService/TFL/TubeStatus/Response.pm b/lib/WebService/TFL/TubeStatus/Response.pm
index 191abe7..b6b104b 100644
--- a/lib/WebService/TFL/TubeStatus/Response.pm
+++ b/lib/WebService/TFL/TubeStatus/Response.pm
@@ -1,30 +1,25 @@
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;
+use namespace::clean;
has lines => (
is => 'ro',
- isa => ArrayRef[LineT],
+ isa => ArrayRef[InstanceOf['WebService::TFL::TubeStatus::Response::Line']],
required => 1,
);
-sub new_from_xml {
- my ($class,$doc,$xpath) = @_;
+sub new_from_response {
+ my ($class,$response_data) = @_;
- 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});
+ return $class->new({
+ lines=> [
+ map { WebService::TFL::TubeStatus::Response::Line->new_from_response($_) }
+ grep { $_->{'$type'} =~ /\bLine\b/ }
+ $response_data->@*
+ ],
+ });
}
1;