diff options
author | Daniel Friesel <derf@finalrewind.org> | 2014-03-02 22:53:23 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2014-03-02 22:53:23 +0100 |
commit | e6e55d5003e7194d97d9f18eced7e17ae4b81ec7 (patch) | |
tree | 6ddc2a3a76b4f7ea0a5ce5dd8a2a72a1d563c79e /lib/Travel | |
parent | bb2ec6920d6ad5aad255f917a4b3fd2c9b588e45 (diff) |
Update platform, platform_db accessors for changed EFA API
Diffstat (limited to 'lib/Travel')
-rw-r--r-- | lib/Travel/Status/DE/EFA.pm | 57 | ||||
-rw-r--r-- | lib/Travel/Status/DE/EFA/Result.pm | 8 |
2 files changed, 35 insertions, 30 deletions
diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm index c92a726..fe54bac 100644 --- a/lib/Travel/Status/DE/EFA.pm +++ b/lib/Travel/Status/DE/EFA.pm @@ -116,7 +116,7 @@ sub new { $self->{tree} = XML::LibXML->load_xml( string => $self->{xml}, ); - # say $self->{tree}->toString(1); + say $self->{tree}->toString(1); $self->check_for_ambiguous(); @@ -314,14 +314,15 @@ sub results { my $rdate = $e_rdate ? sprintf_date($e_rdate) : $date; my $rtime = $e_rtime ? sprintf_time($e_rtime) : $time; - my $platform = $e->getAttribute('platform'); - my $line = $e_line->getAttribute('number'); - my $dest = $e_line->getAttribute('direction'); - my $info = $e_info->textContent; - my $key = $e_line->getAttribute('key'); - my $countdown = $e->getAttribute('countdown'); - my $delay = $e_info->getAttribute('delay') // 0; - my $type = $e_info->getAttribute('name'); + my $platform; # 'platform' attribute is unreliable + my $platform_name = $e->getAttribute('platformName'); + my $line = $e_line->getAttribute('number'); + my $dest = $e_line->getAttribute('direction'); + my $info = $e_info->textContent; + my $key = $e_line->getAttribute('key'); + my $countdown = $e->getAttribute('countdown'); + my $delay = $e_info->getAttribute('delay') // 0; + my $type = $e_info->getAttribute('name'); my $platform_is_db = 0; @@ -329,27 +330,31 @@ sub results { = grep { $_->{identifier} eq $e_line->getAttribute('stateless') } @{ $self->{lines} }; - if ( $platform =~ s{ ^ \# }{}ox ) { + if ( $platform_name =~ m{ ^ Gleis }ox ) { $platform_is_db = 1; } + # Gleis x / Bstg. x -> take x + $platform = ( split( / /, $platform_name ) )[1]; + push( @results, Travel::Status::DE::EFA::Result->new( - date => $rdate, - time => $rtime, - platform => $platform, - platform_db => $platform_is_db, - key => $key, - lineref => $line_obj[0] // undef, - line => $line, - destination => decode( 'UTF-8', $dest ), - countdown => $countdown, - info => decode( 'UTF-8', $info ), - delay => $delay, - sched_date => $date, - sched_time => $time, - type => $type, + date => $rdate, + time => $rtime, + platform => $platform, + platform_db => $platform_is_db, + platform_name => $platform_name, + key => $key, + lineref => $line_obj[0] // undef, + line => $line, + destination => decode( 'UTF-8', $dest ), + countdown => $countdown, + info => decode( 'UTF-8', $info ), + delay => $delay, + sched_date => $date, + sched_time => $time, + type => $type, ) ); } @@ -382,8 +387,8 @@ Travel::Status::DE::EFA - unofficial EFA departure monitor for my $d ($status->results) { printf( - "%s %d %-5s %s\n", - $d->time, $d->platform, $d->line, $d->destination + "%s %-8s %-5s %s\n", + $d->time, $d->platform_name, $d->line, $d->destination ); } diff --git a/lib/Travel/Status/DE/EFA/Result.pm b/lib/Travel/Status/DE/EFA/Result.pm index 151b77a..691c49a 100644 --- a/lib/Travel/Status/DE/EFA/Result.pm +++ b/lib/Travel/Status/DE/EFA/Result.pm @@ -9,8 +9,8 @@ use parent 'Class::Accessor'; our $VERSION = '1.07'; Travel::Status::DE::EFA::Result->mk_ro_accessors( - qw(countdown date delay destination is_cancelled info key line lineref platform - platform_db sched_date sched_time time type) + qw(countdown date delay destination is_cancelled info key line lineref + platform platform_db platform_name sched_date sched_time time type) ); sub new { @@ -48,7 +48,7 @@ departure received by Travel::Status::DE::EFA for my $departure ($status->results) { printf( - "At %s: %s to %s from platform %s\n", + "At %s: %s to %s from platform %d\n", $departure->time, $departure->line, $departure->destination, $departure->platform ); @@ -121,7 +121,7 @@ detail. =item $departure->platform -Departure platform number. +Departure platform number (may not be a number). =item $departure->platform_db |