summaryrefslogtreecommitdiff
path: root/lib/Travel/Routing/DE/VRR.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-11-28 21:14:04 +0100
committerDaniel Friesel <derf@finalrewind.org>2011-11-28 21:14:04 +0100
commit107ca44298c6f65ebfc269646e2184d2adba7810 (patch)
tree0d3bf66981384ee0158da2bc8a87d3551eef9b42 /lib/Travel/Routing/DE/VRR.pm
parent24a55903ddceb8107c527d637f57f7c1d135ef8e (diff)
efa: Add -E option to display total route time and ticket class/price
Diffstat (limited to 'lib/Travel/Routing/DE/VRR.pm')
-rw-r--r--lib/Travel/Routing/DE/VRR.pm18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/Travel/Routing/DE/VRR.pm b/lib/Travel/Routing/DE/VRR.pm
index 7a0abef..45776fa 100644
--- a/lib/Travel/Routing/DE/VRR.pm
+++ b/lib/Travel/Routing/DE/VRR.pm
@@ -432,8 +432,6 @@ sub itdtime_str {
sub parse_part {
my ($self, $route) = @_;
- my $info;
-
my $xp_route = XML::LibXML::XPathExpression->new('./itdPartialRouteList/itdPartialRoute');
my $xp_dep = XML::LibXML::XPathExpression->new('./itdPoint[@usage="departure"]');
my $xp_arr = XML::LibXML::XPathExpression->new('./itdPoint[@usage="arrival"]');
@@ -444,11 +442,23 @@ sub parse_part {
my $xp_mot = XML::LibXML::XPathExpression->new('./itdMeansOfTransport');
my $xp_info = XML::LibXML::XPathExpression->new('./itdInfoTextList/infoTextListElem');
+ my $xp_fare = XML::LibXML::XPathExpression->new('./itdFare/itdSingleTicket');
my @route_parts;
- $info->{vehicle_time} = $route->getAttribute('vehicleTime');
- $info->{duration} = $route->getAttribute('publicDuration');
+ my $info = {
+ duration => $route->getAttribute('publicDuration'),
+ vehicle_time => $route->getAttribute('vehicleTime'),
+ };
+
+ my $e_fare = ( $route->findnodes($xp_fare) )[0];
+
+ if ($e_fare) {
+ $info->{ticket_type} = $e_fare->getAttribute('unitsAdult');
+ $info->{fare_adult} = $e_fare->getAttribute('fareAdult');
+ $info->{fare_child} = $e_fare->getAttribute('fareChild');
+ $info->{ticket_text} = $e_fare->textContent;
+ }
for my $e ( $route->findnodes($xp_route) ) {