blob: dd9855016a40ae968fd733be12c00bb86d8364fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
package Travel::Status::DE::DBWagenreihung::Group;
use strict;
use warnings;
use 5.020;
use utf8;
use parent 'Class::Accessor';
our $VERSION = '0.14';
Travel::Status::DE::DBWagenreihung::Group->mk_ro_accessors(
qw(id train_no type description desc_short origin destination has_sections)
);
sub new {
my ( $obj, %opt ) = @_;
my $ref = \%opt;
return bless( $ref, $obj );
}
sub set_description {
my ( $self, $desc, $short ) = @_;
$self->{description} = $desc;
$self->{desc_short} = $short;
}
sub set_sections {
my ( $self, @sections ) = @_;
$self->{sections} = [@sections];
$self->{has_sections} = 1;
}
sub set_traintype {
my ( $self, $i, $tt ) = @_;
$self->{type} = $tt;
for my $wagon ( $self->wagons ) {
$wagon->set_traintype( $i, $tt );
}
}
sub sort_wagons {
my ($self) = @_;
@{ $self->{wagons} }
= sort { $a->{position}{start_percent} <=> $b->{position}{start_percent} }
@{ $self->{wagons} };
}
sub sections {
my ($self) = @_;
return @{ $self->{sections} // [] };
}
sub wagons {
my ($self) = @_;
return @{ $self->{wagons} // [] };
}
sub TO_JSON {
my ($self) = @_;
my %copy = %{$self};
return {%copy};
}
1;
|