File Coverage

blib/lib/Travel/Status/DE/EFA/Line.pm
Criterion Covered Total %
statement 11 19 57.8
branch n/a
condition 0 2 0.0
subroutine 4 7 57.1
pod 3 3 100.0
total 18 31 58.0


line stmt bran cond sub pod time code
1             package Travel::Status::DE::EFA::Line;
2              
3 2     2   14 use strict;
  2         6  
  2         78  
4 2     2   12 use warnings;
  2         3  
  2         122  
5 2     2   34 use 5.010;
  2         9  
6              
7 2     2   13 use parent 'Class::Accessor';
  2         4  
  2         14  
8              
9             our $VERSION = '3.19';
10              
11             Travel::Status::DE::EFA::Line->mk_ro_accessors(
12             qw(direction mot name number operator route type valid));
13              
14             my @mot_mapping = qw{
15             zug s-bahn u-bahn stadtbahn tram stadtbus regionalbus
16             schnellbus seilbahn schiff ast sonstige
17             };
18              
19             sub new {
20 0     0 1   my ( $obj, %conf ) = @_;
21              
22 0           my $ref = \%conf;
23              
24 0           return bless( $ref, $obj );
25             }
26              
27             sub mot_name {
28 0     0 1   my ($self) = @_;
29              
30 0   0       return $mot_mapping[ $self->{mot} ] // 'sonstige';
31             }
32              
33             sub TO_JSON {
34 0     0 1   my ($self) = @_;
35              
36 0           return { %{$self} };
  0            
37             }
38              
39             1;
40              
41             __END__
42              
43             =head1 NAME
44              
45             Travel::Status::DE::EFA::Line - Information about a line departing at the
46             requested station
47              
48             =head1 SYNOPSIS
49              
50             for my $line ($status->lines) {
51             printf(
52             "line %s -> %s\nRoute: %s\nType %s, operator %s\nValid: %s\n\n",
53             $line->name, $line->direction, $line->route,
54             $line->type, $line->operator, $line->valid
55             );
56             }
57              
58             =head1 VERSION
59              
60             version 3.19
61              
62             =head1 DESCRIPTION
63              
64             Travel::Status::DE::EFA::Line describes a tram/bus/train line departing at the
65             stop requested by Travel::Status::DE::EFA. Note that it only covers one
66             direction, so in most cases, you get two Travel::Status::DE::EFA::Line objects
67             per actual line.
68              
69             =head1 METHODS
70              
71             =head2 ACCESSORS
72              
73             =over
74              
75             =item $line->direction
76              
77             Direction of the line. Name of either the destination stop or one on the way.
78              
79             =item $line->mot
80              
81             Returns the "mode of transport" number for this line. This is usually an
82             integer between 0 and 11.
83              
84             =item $line->mot_name
85              
86             Returns the "mode of transport" for this line, for instance "zug", "s-bahn",
87             "tram" or "sonstige".
88              
89             =item $line->name
90              
91             Name of the line, e.g. "U11", "SB15", "107".
92              
93             =item $line->operator
94              
95             Operator of the line, as in the local transit company responsible for it.
96             May be undefined.
97              
98             =item $line->route
99              
100             Partial route of the line (as string), usually start and destination with two
101             stops in between. May be undefined.
102              
103             Note that start means the actual start of the line, the stop requested by
104             Travel::Status::DE::EFA::Line may not even be included in this listing.
105              
106             =item $line->type
107              
108             Type of the line. Observed values so far are "Bus", "NE", "StraE<szlig>enbahn",
109             "U-Bahn".
110              
111             =item $line->valid
112              
113             When / how long above information is valid.
114              
115             =back
116              
117             =head2 INTERNAL
118              
119             =over
120              
121             =item $line = Travel::Status::DE::EFA::Line->new(I<%data>)
122              
123             Returns a new Travel::Status::DE::EFA::Line object. You should not need to
124             call this.
125              
126             =item $line->TO_JSON
127              
128             Allows the object data to be serialized to JSON.
129              
130             =back
131              
132             =head1 DIAGNOSTICS
133              
134             None.
135              
136             =head1 DEPENDENCIES
137              
138             =over
139              
140             =item Class::Accessor(3pm)
141              
142             =back
143              
144             =head1 BUGS AND LIMITATIONS
145              
146             The B<route> accessor returns a simple string, an array might be better suited.
147              
148             =head1 SEE ALSO
149              
150             Travel::Status::DE::EFA(3pm).
151              
152             =head1 AUTHOR
153              
154             Copyright (C) 2011-2025 Birte Kristina Friesel E<lt>derf@finalrewind.orgE<gt>
155              
156             =head1 LICENSE
157              
158             This module is licensed under the same terms as Perl itself.