summaryrefslogtreecommitdiff
path: root/lib/WebService/TFL/TubeStatus/Response.pm
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2023-12-09 14:07:20 +0000
committerdakkar <dakkar@thenautilus.net>2023-12-09 14:07:20 +0000
commit1a37c7e52d5433e8182d444d12a55fdd9b8a2770 (patch)
tree2f0ed93dd07e6c078a5fb03cb9539ec93772fe23 /lib/WebService/TFL/TubeStatus/Response.pm
parentbump perl (diff)
parentsort buses (diff)
downloadHomePanel-1a37c7e52d5433e8182d444d12a55fdd9b8a2770.tar.gz
HomePanel-1a37c7e52d5433e8182d444d12a55fdd9b8a2770.tar.bz2
HomePanel-1a37c7e52d5433e8182d444d12a55fdd9b8a2770.zip
Merge branch 'new-api'
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;