Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Travel-Status-DE-HAFAS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
derf
Travel-Status-DE-HAFAS
Commits
60a88922
Commit
60a88922
authored
13 years ago
by
Birte Kristina Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Travel::Status::DE::DeutscheBahn::{Departure -> Result}
parent
c84ddac4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/db-ris
+2
-2
2 additions, 2 deletions
bin/db-ris
lib/Travel/Status/DE/DeutscheBahn.pm
+21
-24
21 additions, 24 deletions
lib/Travel/Status/DE/DeutscheBahn.pm
lib/Travel/Status/DE/DeutscheBahn/Result.pm
+179
-0
179 additions, 0 deletions
lib/Travel/Status/DE/DeutscheBahn/Result.pm
with
202 additions
and
26 deletions
bin/db-ris
+
2
−
2
View file @
60a88922
...
...
@@ -61,7 +61,7 @@ sub display_result {
return
;
}
for
my
$d
(
$status
->
departure
s
()
)
{
for
my
$d
(
$status
->
result
s
()
)
{
my
(
@via
,
@via_main
,
@via_show
);
...
...
@@ -130,7 +130,7 @@ version 0.0
=head1 DESCRIPTION
db-ris
s
is an interface to the DeutscheBahn
arrival/
departure monitor
db-ris is an interface to the DeutscheBahn departure monitor
available at L<http://reiseauskunft.bahn.de/bin/bhftafel.exe/dn>.
It requests all departures at I<station> (optionally filtered by date, time,
...
...
This diff is collapsed.
Click to expand it.
lib/Travel/Status/DE/DeutscheBahn.pm
+
21
−
24
View file @
60a88922
...
...
@@ -7,7 +7,7 @@ use 5.010;
use
Carp
qw(confess)
;
use
LWP::
UserAgent
;
use
POSIX
qw(strftime)
;
use
Travel::Status::DE::DeutscheBahn::
Departure
;
use
Travel::Status::DE::DeutscheBahn::
Result
;
use
XML::
LibXML
;
our
$VERSION
=
'
0.0
';
...
...
@@ -81,7 +81,7 @@ sub new_from_html {
return
bless
(
$ref
,
$obj
);
}
sub
departure
s
{
sub
result
s
{
my
(
$self
)
=
@_
;
my
$mode
=
$self
->
{
post
}
->
{
boardType
};
...
...
@@ -139,20 +139,20 @@ sub departures {
}
push
(
@
{
$self
->
{
departure
s
}
},
Travel::Status::DE::DeutscheBahn::
Departure
->
new
(
time
=>
$time
,
train
=>
$train
,
route_raw
=>
$route
,
route
=>
\
@via
,
destination
=>
$dest
,
platform
=>
$platform
,
info
=>
$info
,
@
{
$self
->
{
result
s
}
},
Travel::Status::DE::DeutscheBahn::
Result
->
new
(
time
=>
$time
,
train
=>
$train
,
route_raw
=>
$route
,
route
=>
\
@via
,
route_end
=>
$dest
,
platform
=>
$platform
,
info
=>
$info
,
)
);
}
return
@
{
$self
->
{
departure
s
}
};
return
@
{
$self
->
{
result
s
}
};
}
1
;
...
...
@@ -162,7 +162,7 @@ __END__
=head1 NAME
Travel::Status::DE::DeutscheBahn - Interface to the DeutscheBahn online
departure monitor
arrival/
departure monitor
=head1 SYNOPSIS
...
...
@@ -172,7 +172,7 @@ departure monitor
station => 'Essen Hbf',
);
for my $departure ($status->
departure
s) {
for my $departure ($status->
result
s) {
printf(
"At %s: %s to %s from platform %s\n",
$departure->time,
...
...
@@ -192,9 +192,9 @@ Travel::Status::DE::DeutscheBahn is an interface to the DeutscheBahn
arrival/departure monitor available at
L<http://reiseauskunft.bahn.de/bin/bhftafel.exe/dn>.
It takes a station name and (optional) date and time and reports all
departures at that station starting at the specified point in time (now if
unspecified).
By default, it will list the next 20 departures.
It takes a station name and (optional) date and time and reports all
arrivals
or
departures at that station starting at the specified point in time (now if
unspecified).
=head1 METHODS
...
...
@@ -223,9 +223,6 @@ Time to report for. Defaults to now.
By default, Travel::Status::DE::DeutscheBahn reports train departures
(B<dep>). Set this to B<arr> to get arrivals instead.
For arrivals, the C<departures()> method will report the arrival time, the
train's origin and their route until the selected I<station>.
=item B<mot> => I<\%hashref>
Modes of transport to show. Accepted keys are: B<ice> (ICE trains), B<ic_ec>
...
...
@@ -240,10 +237,10 @@ By default, the following are shown: ice, ic_ec, d, nv, s.
=back
=item $status->
departure
s()
=item $status->
result
s()
Returns a list of departures
(20 by default)
. Each list element is a
Travel::Status::DE::DeutscheBahn::
Departure
(3pm) object.
Returns a list of
arrivals/
departures. Each list element is a
Travel::Status::DE::DeutscheBahn::
Result
(3pm) object.
=back
...
...
@@ -269,7 +266,7 @@ Unknown.
=head1 SEE ALSO
mris(1), Travel::Status::DE::DeutscheBahn::
Departure
(3pm).
mris(1), Travel::Status::DE::DeutscheBahn::
Result
(3pm).
=head1 AUTHOR
...
...
This diff is collapsed.
Click to expand it.
lib/Travel/Status/DE/DeutscheBahn/
Departure
.pm
→
lib/Travel/Status/DE/DeutscheBahn/
Result
.pm
+
179
−
0
View file @
60a88922
package
Travel::Status::DE::DeutscheBahn::
Departure
;
package
Travel::Status::DE::DeutscheBahn::
Result
;
use
strict
;
use
warnings
;
...
...
@@ -8,8 +8,8 @@ use parent 'Class::Accessor';
our
$VERSION
=
'
0.0
';
Travel::Status::DE::DeutscheBahn::
Departure
->
mk_ro_accessors
(
qw(time train
destination
platform info)
);
Travel::Status::DE::DeutscheBahn::
Result
->
mk_ro_accessors
(
qw(time train
route_end
platform info)
);
sub
new
{
my
(
$obj
,
%conf
)
=
@_
;
...
...
@@ -19,6 +19,18 @@ sub new {
return
bless
(
$ref
,
$obj
);
}
sub
destination
{
my
(
$self
)
=
@_
;
return
$self
->
{
route_end
};
}
sub
origin
{
my
(
$self
)
=
@_
;
return
$self
->
{
route_end
};
}
sub
route
{
my
(
$self
)
=
@_
;
...
...
@@ -31,12 +43,12 @@ __END__
=head1 NAME
Travel::Status::DE::DeutscheBahn::
Departure
- Information about a single
departure received by Travel::Status::DE::DeutscheBahn
Travel::Status::DE::DeutscheBahn::
Result
- Information about a single
arrival/
departure received by Travel::Status::DE::DeutscheBahn
=head1 SYNOPSIS
for my $departure ($status->
departure
s) {
for my $departure ($status->
result
s) {
printf(
"At %s: %s to %s from platform %s\n",
$departure->time,
...
...
@@ -46,56 +58,74 @@ departure received by Travel::Status::DE::DeutscheBahn
);
}
# or (depending on module setup)
for my $arrival ($status->results) {
printf(
"At %s: %s from %s on platform %s\n",
$arrival->time,
$arrival->train,
$arrival->origin,
$arrival->platform,
);
}
=head1 VERSION
version 0.0
=head1 DESCRIPTION
Travel::Status::DE::DeutscheBahn::
Departure
describes a single departure
as
obtained by Travel::Status::DE::DeutscheBahn. It contains information about
the platform,
departure time, destination
and more.
Travel::Status::DE::DeutscheBahn::
Result
describes a single
arrival/
departure
as
obtained by Travel::Status::DE::DeutscheBahn. It contains information about
the platform,
time, route
and more.
=head1 ACCESSORS
=head1 METHODS
=head2 ACCESSORS
=over
=item $
departure->destination
=item $
result->route_end
Returns the name of the destination station, e.g. "Dortmund Hbf".
Returns the last element of the route. Depending on how you set up
Travel::Status::DE::DeutscheBahn (arrival or departure listing), this is
either the train's destination or its origin station.
=item $departure->info
For convenienc, this method can also be called as B<destination> or B<origin>.
=item $result->info
Returns additional information, usually wether the train is on time or
delayed.
=item $
departure
->platform
=item $
result
->platform
Returns the platform from which the train will depart.
Returns the platform from which the train will depart / at which it will
arrive.
=item $
departure
->route
=item $
result
->route
Returns a list of station names the train will pass between the selected
station and its destination.
station and its
origin/
destination.
=item $
departure
->time
=item $
result
->time
Returns the departure time as string in "hh:mm" format.
Returns the
arrival/
departure time as string in "hh:mm" format.
=item $
departure
->train
=item $
result
->train
Returns the line / train name, either in a format like "S 1" (S-Bahn line 1)
or "RE 10111" (RegionalExpress train 10111, no line information).
=back
=head
1 METHODS
=head
2 INTERNAL
=over
=item $
departure
= Travel::Status::DE::DeutscheBahn::
Departure
->new(I<%data>)
=item $
result
= Travel::Status::DE::DeutscheBahn::
Result
->new(I<%data>)
Returns a new Travel::Status::DE::DeutscheBahn::
Departure
object.
Returns a new Travel::Status::DE::DeutscheBahn::
Result
object.
You usually do not need to call this.
Required I<data>:
...
...
@@ -110,7 +140,7 @@ Required I<data>:
=item B<route> => I<arrayref>
=item B<
destination
> => I<string>
=item B<
route_end
> => I<string>
=item B<platform> => I<string>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment