summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2013-12-23 13:06:03 +0100
committerDaniel Friesel <derf@finalrewind.org>2013-12-23 13:06:03 +0100
commited13b967ddc14b3c840e260a61e4f009645a6c21 (patch)
tree15137fb7c10c39d977befd538f2b21e82a6ffeff /lib/Travel/Status/DE
parentfa93b66e6322de44af80e479bf5d4fa95fb7c788 (diff)
URA.pm: Move parse logic to separate function
Diffstat (limited to 'lib/Travel/Status/DE')
-rw-r--r--lib/Travel/Status/DE/URA.pm24
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/Travel/Status/DE/URA.pm b/lib/Travel/Status/DE/URA.pm
index 5280060..610bf10 100644
--- a/lib/Travel/Status/DE/URA.pm
+++ b/lib/Travel/Status/DE/URA.pm
@@ -55,15 +55,7 @@ sub new {
$self->{raw_str} = $response->decoded_content;
- for my $dep ( split( /\r\n/, $self->{raw_str} ) ) {
- $dep =~ s{^\[}{};
- $dep =~ s{\]$}{};
-
- # first field == 4 => version information, no departure
- if ( substr( $dep, 0, 1 ) != 4 ) {
- push( @{ $self->{raw_list} }, [ split( /"?,"?/, $dep ) ] );
- }
- }
+ $self->parse_raw_data;
return $self;
}
@@ -73,7 +65,17 @@ sub new_from_raw {
my $self = { raw_str => $opt{raw_str}, };
- for my $dep ( split( /\r\n/, $self->{raw} ) ) {
+ bless( $self, $class );
+
+ $self->parse_raw_data;
+
+ return $self;
+}
+
+sub parse_raw_data {
+ my ($self) = @_;
+
+ for my $dep ( split( /\r\n/, $self->{raw_str} ) ) {
$dep =~ s{^\[}{};
$dep =~ s{\]$}{};
@@ -83,7 +85,7 @@ sub new_from_raw {
}
}
- return bless( $self, $class );
+ return $self;
}
sub errstr {