summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/db-wagenreihung10
-rw-r--r--lib/Travel/Status/DE/DBWagenreihung.pm17
2 files changed, 24 insertions, 3 deletions
diff --git a/bin/db-wagenreihung b/bin/db-wagenreihung
index 100f4b1..bae97b9 100755
--- a/bin/db-wagenreihung
+++ b/bin/db-wagenreihung
@@ -13,6 +13,8 @@ use Travel::Status::DE::DBWagenreihung;
my $developer_mode = 0;
+binmode( STDOUT, ':encoding(utf-8)' );
+
sub show_help {
my ($code) = @_;
@@ -77,7 +79,7 @@ for my $section ( $wr->sections ) {
$spacing_left++;
}
- printf( "|%s%s%s|",
+ printf( "ā–%s%s%sā–•",
' ' x $spacing_left,
$section->name,
' ' x $spacing_right );
@@ -85,7 +87,8 @@ for my $section ( $wr->sections ) {
print "\n";
my @start_percentages = map { $_->{position}{start_percent} } $wr->wagons;
-print ' ' x ( min @start_percentages );
+print ' ' x ( ( min @start_percentages ) - 1 );
+print $wr->direction == 100 ? '>' : '<';
for my $wagon ( $wr->wagons ) {
my $wagon_length
@@ -100,7 +103,7 @@ for my $wagon ( $wr->wagons ) {
my $wagon_desc = $wagon->number || '?';
if ( $wagon->is_locomotive or $wagon->is_powercar ) {
- $wagon_desc = '<->';
+ $wagon_desc = ' ā–  ';
}
my $class_color = '';
@@ -118,4 +121,5 @@ for my $wagon ( $wr->wagons ) {
' ' x $spacing_left, $class_color, $wagon_desc,
$col_reset, ' ' x $spacing_right );
}
+print $wr->direction == 100 ? '>' : '<';
print "\n";
diff --git a/lib/Travel/Status/DE/DBWagenreihung.pm b/lib/Travel/Status/DE/DBWagenreihung.pm
index c879d14..5308961 100644
--- a/lib/Travel/Status/DE/DBWagenreihung.pm
+++ b/lib/Travel/Status/DE/DBWagenreihung.pm
@@ -86,6 +86,23 @@ sub error {
return $self->{errstr};
}
+sub direction {
+ my ($self) = @_;
+
+ my @wagons = $self->wagons;
+
+ if ( not @wagons ) {
+ return undef;
+ }
+
+ if ( $wagons[0]->{position}{start_percent}
+ > $wagons[-1]{position}{start_percent} )
+ {
+ return 0;
+ }
+ return 100;
+}
+
sub sections {
my ($self) = @_;