File Coverage

blib/lib/Travel/Status/DE/EFA/Info.pm
Criterion Covered Total %
statement 11 21 52.3
branch n/a
condition 0 2 0.0
subroutine 4 6 66.6
pod 1 2 50.0
total 16 31 51.6


line stmt bran cond sub pod time code
1             package Travel::Status::DE::EFA::Info;
2              
3 2     2   16 use strict;
  2         5  
  2         95  
4 2     2   13 use warnings;
  2         4  
  2         145  
5 2     2   40 use 5.010;
  2         7  
6              
7 2     2   14 use parent 'Class::Accessor';
  2         5  
  2         14  
8              
9             our $VERSION = '3.19';
10              
11             Travel::Status::DE::EFA::Info->mk_ro_accessors(
12             qw(link_url link_text subject content subtitle additional_text));
13              
14             sub new {
15 0     0 1   my ( $obj, %opt ) = @_;
16              
17 0           my $json = $opt{json};
18              
19             my $ref = {
20             param => {},
21             link_url => $json->{infoLinkURL},
22             link_text => $json->{infoLinkText},
23             subject => $json->{infoText}{subject},
24             content => $json->{infoText}{content},
25             subtitle => $json->{infoText}{subtitle},
26             additional_text => $json->{infoText}{additionalText},
27 0           };
28              
29 0   0       for my $param ( @{ $json->{paramList} // [] } ) {
  0            
30 0           $ref->{param}{ $param->{name} } = $param->{value};
31             }
32              
33 0           return bless( $ref, $obj );
34             }
35              
36             sub TO_JSON {
37 0     0 0   my ($self) = @_;
38              
39 0           return { %{$self} };
  0            
40             }
41              
42             1;
43              
44             __END__
45              
46             =head1 NAME
47              
48             Travel::Status::DE::EFA::Info - Information about a public transit stop
49              
50             =head1 SYNOPSIS
51              
52             if ( $info->subject and $info->subtitle ne $info->subject ) {
53             printf( "# %s\n%s\n", $info->subtitle, $info->subject );
54             }
55             else {
56             printf( "# %s\n", $info->subtitle );
57             }
58              
59             =head1 VERSION
60              
61             version 3.19
62              
63             =head1 DESCRIPTION
64              
65             Travel::Status::DE::EFA::Info holds a single information message related to
66             a specific public transit stop.
67              
68             =head1 ACCESSORS
69              
70             All accessors may return undef.
71             Individual accessors may return identical strings.
72             Strings may contain HTML elements.
73              
74             =over
75              
76             =item $info->additional_text
77              
78             =item $info->content
79              
80             =item $info->link_url
81              
82             URL to a site related to this information message.
83             The site may or may not hold additional data.
84              
85             =item $info->link_text
86              
87             Text for linking to link_url.
88              
89             =item $info->param
90              
91             Hashref of parameters, e.g. C<< incidentDateTime >> (string describing the
92             date/time range during which this message is valid).
93              
94             =item $info->subject
95              
96             =item $info->subtitle
97              
98             =back
99              
100             =head1 DIAGNOSTICS
101              
102             None.
103              
104             =head1 DEPENDENCIES
105              
106             =over
107              
108             =item Class::Accessor(3pm)
109              
110             =back
111              
112             =head1 BUGS AND LIMITATIONS
113              
114             This module is a Work in Progress.
115             Its API may change between minor versions.
116              
117             =head1 SEE ALSO
118              
119             Travel::Status::DE::EFA(3pm).
120              
121             =head1 AUTHOR
122              
123             Copyright (C) 2024-2025 Birte Kristina Friesel E<lt>derf@finalrewind.orgE<gt>
124              
125             =head1 LICENSE
126              
127             This module is licensed under the same terms as Perl itself.