summaryrefslogtreecommitdiff
path: root/lib/Travel/Status
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-01-28 20:27:03 +0100
committerDaniel Friesel <derf@finalrewind.org>2022-01-28 20:27:03 +0100
commitc5c197f16c7d77ef4e1592ceb19116c71f319791 (patch)
tree3fa3eb0604b92d81fa96d2c2d573eae84ece492e /lib/Travel/Status
parentf7290c4a75b955f981b481e4c08d09687958e4bf (diff)
IRIS: refactor ahead of promises support
Diffstat (limited to 'lib/Travel/Status')
-rw-r--r--lib/Travel/Status/DE/IRIS.pm27
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm
index 9aef5a2..f46cb2b 100644
--- a/lib/Travel/Status/DE/IRIS.pm
+++ b/lib/Travel/Status/DE/IRIS.pm
@@ -65,6 +65,15 @@ sub new {
bless( $self, $class );
+ my $lookahead_steps = int( $self->{lookahead} / 60 );
+ if ( ( 60 - $self->{datetime}->minute ) < ( $self->{lookahead} % 60 ) ) {
+ $lookahead_steps++;
+ }
+ my $lookbehind_steps = int( $self->{lookbehind} / 60 );
+ if ( $self->{datetime}->minute < ( $self->{lookbehind} % 60 ) ) {
+ $lookbehind_steps++;
+ }
+
if ( not $self->{user_agent} ) {
my %lwp_options = %{ $opt{lwp_options} // { timeout => 10 } };
$self->{user_agent} = LWP::UserAgent->new(%lwp_options);
@@ -110,15 +119,6 @@ sub new {
return $self;
}
- my $lookahead_steps = int( $self->{lookahead} / 60 );
- if ( ( 60 - $self->{datetime}->minute ) < ( $self->{lookahead} % 60 ) ) {
- $lookahead_steps++;
- }
- my $lookbehind_steps = int( $self->{lookbehind} / 60 );
- if ( $self->{datetime}->minute < ( $self->{lookbehind} % 60 ) ) {
- $lookbehind_steps++;
- }
-
my $dt_req = $self->{datetime}->clone;
$self->get_timetable( $self->{station}{uic}, $dt_req );
for ( 1 .. $lookahead_steps ) {
@@ -133,6 +133,13 @@ sub new {
$self->get_realtime;
+ $self->postprocess_results;
+
+ return $self;
+}
+
+sub postprocess_results {
+ my ($self) = @_;
if ( not $self->{keep_transfers} ) {
# tra (transfer?) indicates a train changing its ID, so there are two
@@ -173,8 +180,6 @@ sub new {
# same goes for replacement refs (the <ref> tag in the fchg document)
$self->create_replacement_refs;
-
- return $self;
}
sub get_with_cache {