summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/EFA.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-09-28 18:06:25 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-09-28 18:06:25 +0200
commit53fcd15fe7667628f4d5c4f2c1b2dc49f174d67c (patch)
treea90b3a2f16b3b628bcf0488ed985736546b868bd /lib/Travel/Status/DE/EFA.pm
parent14055f3ecdeaada8f0e871f5943417bc236738a9 (diff)
EFA: Handle ambiguous input properly (explicit accessors for candidate lists)
Diffstat (limited to 'lib/Travel/Status/DE/EFA.pm')
-rw-r--r--lib/Travel/Status/DE/EFA.pm47
1 files changed, 35 insertions, 12 deletions
diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm
index 5b1e36a..c9123df 100644
--- a/lib/Travel/Status/DE/EFA.pm
+++ b/lib/Travel/Status/DE/EFA.pm
@@ -167,6 +167,24 @@ sub errstr {
return $self->{errstr};
}
+sub name_candidates {
+ my ($self) = @_;
+
+ if ( $self->{name_candidates} ) {
+ return @{ $self->{name_candidates} };
+ }
+ return;
+}
+
+sub place_candidates {
+ my ($self) = @_;
+
+ if ( $self->{place_candidates} ) {
+ return @{ $self->{place_candidates} };
+ }
+ return;
+}
+
sub sprintf_date {
my ($e) = @_;
@@ -222,21 +240,16 @@ sub check_for_ambiguous {
my $s_name = $e_name->getAttribute('state');
if ( $s_place eq 'list' ) {
- $self->{errstr} = sprintf(
- 'Ambiguous place input: %s',
- join( q{ | },
- map { decode( 'UTF-8', $_->textContent ) }
- @{ $e_place->findnodes($xp_place_elem) } )
- );
+ $self->{place_candidates} = [ map { decode( 'UTF-8', $_->textContent ) }
+ @{ $e_place->findnodes($xp_place_elem) } ];
+ $self->{errstr} = 'ambiguous place parameter';
return;
}
if ( $s_name eq 'list' ) {
- $self->{errstr} = sprintf(
- 'Ambiguous name input: %s',
- join( q{ | },
- map { decode( 'UTF-8', $_->textContent ) }
- @{ $e_name->findnodes($xp_name_elem) } )
- );
+ $self->{name_candidates} = [ map { decode( 'UTF-8', $_->textContent ) }
+ @{ $e_name->findnodes($xp_name_elem) } ];
+
+ $self->{errstr} = 'ambiguous name parameter';
return;
}
if ( $s_place eq 'notidentified' ) {
@@ -704,6 +717,16 @@ will return ("Essen", "Martinstr.").
Returns a list of Travel::Status::DE::EFA::Line(3pm) objects, each one
describing one line servicing the selected station.
+=item $status->name_candidates
+
+Returns a list of B<name> candidates if I<name> is ambiguous. Returns
+nothing (undef / empty list) otherwise.
+
+=item $status->place_candidates
+
+Returns a list of B<place> candidates if I<place> is ambiguous. Returns
+nothing (undef / empty list) otherwise.
+
=item $status->results
Returns a list of Travel::Status::DE::EFA::Result(3pm) objects, each one describing