diff options
author | Daniel Friesel <derf@finalrewind.org> | 2018-11-26 20:10:24 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2018-11-26 20:10:24 +0100 |
commit | be0380ac6020556120269a0deecba7ffef63dcb0 (patch) | |
tree | ad5269cad598da7a3b24094d3f16ab4d558e5f9d /lib/Travel/Status/DE/DBWagenreihung | |
parent | 7085318c1ae616bc2fbd79c335276a0d3420e50f (diff) |
Use ::Section module for section data
Diffstat (limited to 'lib/Travel/Status/DE/DBWagenreihung')
-rw-r--r-- | lib/Travel/Status/DE/DBWagenreihung/Section.pm | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/Travel/Status/DE/DBWagenreihung/Section.pm b/lib/Travel/Status/DE/DBWagenreihung/Section.pm new file mode 100644 index 0000000..780031c --- /dev/null +++ b/lib/Travel/Status/DE/DBWagenreihung/Section.pm @@ -0,0 +1,34 @@ +package Travel::Status::DE::DBWagenreihung::Section; + +use strict; +use warnings; +use 5.020; +use utf8; + +use parent 'Class::Accessor'; + +our $VERSION = '0.00'; + +Travel::Status::DE::DBWagenreihung::Section->mk_ro_accessors( + qw(name start_percent end_percent length_percent start_meters end_meters length_meters) +); + +sub new { + my ( $obj, %opt ) = @_; + my $ref = \%opt; + + $ref->{length_meters} = $ref->{end_meters} - $ref->{start_meters}; + $ref->{length_percent} = $ref->{end_percent} - $ref->{start_percent}; + + return bless( $ref, $obj ); +} + +sub TO_JSON { + my ($self) = @_; + + my %copy = %{$self}; + + return {%copy}; +} + +1; |