summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/IRIS/Result.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-04-27 18:14:57 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-04-27 18:14:57 +0200
commit6d8a390dcff71ef1c4b7755dac97c0e1111e5230 (patch)
tree420fd3a425d1e2f4b130cf0b01dfe41a12bfda63 /lib/Travel/Status/DE/IRIS/Result.pm
parenta99025f2d9ba31399e38d34ba95427f56866308d (diff)
parse <ref> in fchg, add replacement support to backend and frontend
Diffstat (limited to 'lib/Travel/Status/DE/IRIS/Result.pm')
-rw-r--r--lib/Travel/Status/DE/IRIS/Result.pm58
1 files changed, 54 insertions, 4 deletions
diff --git a/lib/Travel/Status/DE/IRIS/Result.pm b/lib/Travel/Status/DE/IRIS/Result.pm
index ebcb5be..85ee1bf 100644
--- a/lib/Travel/Status/DE/IRIS/Result.pm
+++ b/lib/Travel/Status/DE/IRIS/Result.pm
@@ -96,8 +96,8 @@ my %translation = (
Travel::Status::DE::IRIS::Result->mk_ro_accessors(
qw(arrival classes date datetime delay departure is_cancelled is_transfer
- is_unscheduled is_wing line_no old_train_id
- old_train_no platform raw_id realtime_xml route_start route_end
+ is_unscheduled is_wing line_no old_train_id old_train_no platform raw_id
+ realtime_xml route_start route_end
sched_arrival sched_departure sched_platform sched_route_start
sched_route_end start stop_no time train_id train_no transfer type
unknown_t unknown_o wing_id)
@@ -309,10 +309,10 @@ sub set_realtime {
return $self;
}
-sub set_ref {
+sub add_raw_ref {
my ( $self, %attrib ) = @_;
- # TODO
+ push( @{ $self->{refs} }, \%attrib );
return $self;
}
@@ -337,6 +337,7 @@ sub add_arrival_wingref {
$ref->{is_wing} = 1;
weaken($ref);
push( @{ $self->{arrival_wings} }, $ref );
+ return $self;
}
sub add_departure_wingref {
@@ -345,6 +346,25 @@ sub add_departure_wingref {
$ref->{is_wing} = 1;
weaken($ref);
push( @{ $self->{departure_wings} }, $ref );
+ return $self;
+}
+
+sub add_reference {
+ my ( $self, $ref ) = @_;
+
+ $ref->add_inverse_reference($self);
+ weaken($ref);
+ push( @{ $self->{replacement_for} }, $ref );
+ return $self;
+}
+
+# never called externally
+sub add_inverse_reference {
+ my ( $self, $ref ) = @_;
+
+ weaken($ref);
+ push( @{ $self->{replaced_by} }, $ref );
+ return $self;
}
# List::Compare does not keep the order of its arguments (even with unsorted).
@@ -476,6 +496,24 @@ sub departure_wings {
return;
}
+sub replaced_by {
+ my ($self) = @_;
+
+ if ( $self->{replaced_by} ) {
+ return @{ $self->{replaced_by} };
+ }
+ return;
+}
+
+sub replacement_for {
+ my ($self) = @_;
+
+ if ( $self->{replacement_for} ) {
+ return @{ $self->{replacement_for} };
+ }
+ return;
+}
+
sub dump_message_codes {
my ($self) = @_;
@@ -912,6 +950,18 @@ available.
This is a developer option. It may be removed without prior warning.
+=item $result->replaced_by
+
+Returns a list of references to Travel::Status::DE::IRIS::Result(3pm) objects
+which replace the (usually cancelled) arrival/departure of this train.
+Returns nothing (false / empty list) otherwise.
+
+=item $result->replacement_for
+
+Returns a list of references to Travel::Status::DE::IRIS::Result(3pm) objects
+which this (usually unplanned) train is meant to replace.
+Returns nothing (false / empty list) otherwise.
+
=item $result->route
List of all stations served by this train, according to its schedule. Does