Commit db2e06e1 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

add support for canceled / additional stops. untested at the moment

parent 34793a5b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ Module::Build->new(
		'DateTime::Format::Strptime' => 0,
		'Encode' => 0,
		'Getopt::Long' => 0,
		'List::Compare' => '0.29',
		'List::MoreUtils' => 0,
		'List::Util' => 0,
		'LWP::UserAgent' => 0,
+19 −8
Original line number Diff line number Diff line
@@ -82,6 +82,8 @@ if ($time) {

for my $efield (@edata_pre) {
	given ($efield) {
		when ('a') { $edata{additional} = 1 }
		when ('c') { $edata{canceled}   = 1 }
		when ('d') { $edata{delay}      = 1 }
		when ('D') { $edata{delays}     = 1 }
		when ('f') { $edata{fullroute}  = 1 }
@@ -247,6 +249,15 @@ sub display_result {
			print "\n";
		}

		if ( $edata{additional} and $d->additional_stops ) {
			printf( "Zusätzlicher Halt in: %s\n",
				join( q{, }, $d->additional_stops ) );
		}

		if ( $edata{canceled} and $d->canceled_stops ) {
			printf( "Ohne Halt in: %s\n", join( q{, }, $d->canceled_stops ) );
		}

		if ( $edata{fullroute} ) {
			print "\n" . join( "\n", $d->route ) . "\n\n";
		}
+20 −1
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ use parent 'Class::Accessor';
use Carp qw(cluck);
use DateTime;
use DateTime::Format::Strptime;
use List::Compare;
use List::MoreUtils qw(none uniq firstval);

our $VERSION = '0.05';
@@ -189,6 +190,24 @@ sub add_tl {
	return $self;
}

sub additional_stops {
	my ($self) = @_;

	$self->{comparator}
	  //= List::Compare->new( $self->{sched_route_post}, $self->{route_post} );

	return $self->{comparator}->get_complement;
}

sub canceled_stops {
	my ($self) = @_;

	$self->{comparator}
	  //= List::Compare->new( $self->{sched_route_post}, $self->{route_post} );

	return $self->{comparator}->get_unique;
}

sub merge_with_departure {
	my ( $self, $result ) = @_;