summaryrefslogtreecommitdiff
path: root/lib/Travel/Routing/DE/EFA.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-06-25 11:44:08 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-06-25 11:44:08 +0200
commitb32bf2d4beda9925f7ffec3d4fbe7cf0352ab997 (patch)
treefe10d054e4ca64b287eb739297afb9426b871257 /lib/Travel/Routing/DE/EFA.pm
parent5fc7f99bf99c5a90cc201abf0b91671c89b7d4d3 (diff)
Move messages to Travel::Routing::DE::EFA::Route::Message objects
Diffstat (limited to 'lib/Travel/Routing/DE/EFA.pm')
-rw-r--r--lib/Travel/Routing/DE/EFA.pm31
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/Travel/Routing/DE/EFA.pm b/lib/Travel/Routing/DE/EFA.pm
index a87677f..ed4c0f7 100644
--- a/lib/Travel/Routing/DE/EFA.pm
+++ b/lib/Travel/Routing/DE/EFA.pm
@@ -9,6 +9,7 @@ no if $] >= 5.018, warnings => "experimental::smartmatch";
use Carp qw(cluck);
use Encode qw(decode encode);
use Travel::Routing::DE::EFA::Route;
+use Travel::Routing::DE::EFA::Route::Message;
use LWP::UserAgent;
use XML::LibXML;
@@ -510,16 +511,26 @@ sub parse_cur_info {
my $e_subtitle = ( $node->findnodes($xp_subtitle) )[0];
my $e_content = ( $node->findnodes($xp_content) )[0];
- my $ret = {
- summary => $e_text->textContent,
- subject => $e_subject->textContent,
- subtitle => $e_subtitle->textContent,
- content => $e_content->textContent,
- };
- for my $key ( keys %{$ret} ) {
- $ret->{$key} = decode( 'UTF-8', $ret->{$key} );
+ my %msg = (
+ summary => $e_text->textContent,
+ subject => $e_subject->textContent,
+ subtitle => $e_subtitle->textContent,
+ raw_content => $e_content->textContent,
+ );
+ for my $key ( keys %msg ) {
+ $msg{$key} = decode( 'UTF-8', $msg{$key} );
}
- return $ret;
+ return Travel::Routing::DE::EFA::Route::Message->new(%msg);
+}
+
+sub parse_reg_info {
+ my ( $self, $node ) = @_;
+
+ my %msg = (
+ summary => decode( 'UTF-8', $node->textContent ),
+ );
+
+ return Travel::Routing::DE::EFA::Route::Message->new(%msg);
}
sub parse_xml_part {
@@ -691,7 +702,7 @@ sub parse_xml_part {
}
$hash->{regular_notes}
- = [ map { decode( 'UTF-8', $_->textContent ) } @e_sinfo ];
+ = [ map { $self->parse_reg_info($_) } @e_sinfo ];
$hash->{current_notes} = [ map { $self->parse_cur_info($_) } @e_cinfo ];
push( @route_parts, $hash );