NYC.pm

filter: Statementstmt 100% 14 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 19 / 19 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary NYC/Line/BMTCanarsie.pm »
1 package Map::Tube::NYC;
2  
3 $Map::Tube::NYC::VERSION = '0.60';
4 $Map::Tube::NYC::AUTHORITY = 'cpan:MANWAR';
5  
6 =head1 NAME
7  
8 Map::Tube::NYC - Interface to the NYC Subway Map.
9  
10 =head1 VERSION
11  
12 Version 0.60
13  
14 =cut
15  
16 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use File::ShareDir ':ALL';
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 has xml => (is => 'ro', default => sub { return dist_file('Map-Tube-NYC', 'nyc-map.xml') });
24  
25 with 'Map::Tube';
26  
27 =encoding utf8
28  
29 =head1 DESCRIPTION
30  
31 It currently provides functionality to find the shortest route between the two
32 given nodes. It covers the following subway lines just yet:
33  
34 =over 2
35  
36 =item * L<IND Sixth Avenue Line|Map::Tube::NYC::Line::INDSixthAvenue>
37  
38 =item * L<IND Eighth Avenue Line|Map::Tube::NYC::Line::INDEighthAvenue>
39  
40 =item * L<IND Crosstown Line|Map::Tube::NYC::Line::INDCrosstown>
41  
42 =item * L<IRT Flushing Line|Map::Tube::NYC::Line::IRTFlushing>
43  
44 =item * L<BMT Canarsie Line|Map::Tube::NYC::Line::BMTCanarsie>
45  
46 =item * L<BMT Nassau Street Line|Map::Tube::NYC::Line::BMTNassauStreet>
47  
48 =item * L<IRT Lexington Avenue Line|Map::Tube::NYC::Line::IRTLexingtonAvenue>
49  
50 =back
51  
52 =head1 TODO (Subway Lines)
53  
54 =over 2
55  
56 =item * BMT Broadway Line
57  
58 =item * IRT Broadway Line
59  
60 =back
61  
62 =head1 CONSTRUCTOR
63  
64 The constructor DO NOT expects parameters.This setup the default node definitions.
65  
66 use strict; use warnings;
67 use Map::Tube::NYC;
68  
69 my $subway = Map::Tube::NYC->new;
70  
71 =head1 METHODS
72  
73 =head2 get_shortest_route($from, $to)
74  
75 It expects C<$from> and C<$to> station name, required param. It returns an object
76 of type L<Map::Tube::Route>. On error it throws exception of type L<Map::Tube::Exception>.
77  
78 use strict; use warnings;
79 use Map::Tube::NYC;
80  
81 my $subway = Map::Tube::NYC->new;
82 my $route = $subway->get_shortest_route('Canal Street', 'High Street');
83  
84 print "Route: $route\n";;
85  
86 =head2 as_image($line_name)
87  
88 It expects the plugin L<Map::Tube::Plugin::Graph> to be installed. Returns line
89 image as base64 encoded string if C<$line_name> passed in otherwise it returns
90 base64 encoded string of the entire map.
91  
92 use strict; use warnings;
93 use MIME::Base64;
94 use Map::Tube::NYC;
95  
96 my $subway = Map::Tube::NYC->new;
97 my $map = $subway->name;
98 open(my $IMAGE, ">", "$map.png")
99 or die "ERROR: Can't open [$map.png]: $!";
100 binmode($IMAGE);
101 print $IMAGE decode_base64($subway->as_image);
102 close($IMAGE);
103  
104 The L<NYC Subway Map|https://raw.githubusercontent.com/manwar/Map-Tube-NYC/master/maps/NYC-Subway.png>
105 map as generated by plugin L<Map::Tube::Plugin::Graph>.
106  
107 =begin html
108  
109 <a href = "https://raw.githubusercontent.com/manwar/Map-Tube-NYC/master/maps/NYC-Subway.png">
110 <img src = "https://raw.githubusercontent.com/manwar/Map-Tube-NYC/master/maps/NYC-Subway.png"
111 alt = "NYC Subway Map"
112 width = "500px"
113 height = "700px"/>
114 </a>
115  
116 =end html
117  
118 =head1 AUTHOR
119  
120 Mohammad S Anwar, C<< <mohammad.anwar at yahoo.com> >>
121  
122 =head1 REPOSITORY
123  
124 L<https://github.com/manwar/Map-Tube-NYC>
125  
126 =head1 BUGS
127  
128 Please report any bugs/feature requests to C<bug-map-tube-nyc at rt.cpan.org>, or
129 through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Map-Tube-NYC>.
130 I will be notified, and then you'll automatically be notified of progress on your
131 bug as I make changes.
132  
133 =head1 SUPPORT
134  
135 You can find documentation for this module with the perldoc command.
136  
137 perldoc Map::Tube::NYC
138  
139 You can also look for information at:
140  
141 =over 4
142  
143 =item * RT: CPAN's request tracker (report bugs here)
144  
145 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Map-Tube-NYC>
146  
147 =item * AnnoCPAN: Annotated CPAN documentation
148  
149 L<http://annocpan.org/dist/Map-Tube-NYC>
150  
151 =item * CPAN Ratings
152  
153 L<http://cpanratings.perl.org/d/Map-Tube-NYC>
154  
155 =item * Search CPAN
156  
157 L<http://search.cpan.org/dist/Map-Tube-NYC/>
158  
159 =back
160  
161 =head1 LICENSE AND COPYRIGHT
162  
163 Copyright (C) 2014 - 2016 Mohammad S Anwar.
164  
165 This program is free software; you can redistribute it and/or modify it under
166 the terms of the the Artistic License (2.0). You may obtain a copy of the full
167 license at:
168  
169 L<http://www.perlfoundation.org/artistic_license_2_0>
170  
171 Any use, modification, and distribution of the Standard or Modified Versions is
172 governed by this Artistic License.By using, modifying or distributing the Package,
173 you accept this license. Do not use, modify, or distribute the Package, if you do
174 not accept this license.
175  
176 If your Modified Version has been derived from a Modified Version made by someone
177 other than you,you are nevertheless required to ensure that your Modified Version
178 complies with the requirements of this license.
179  
180 This license does not grant you the right to use any trademark, service mark,
181 tradename, or logo of the Copyright Holder.
182  
183 This license includes the non-exclusive, worldwide, free-of-charge patent license
184 to make, have made, use, offer to sell, sell, import and otherwise transfer the
185 Package with respect to any patent claims licensable by the Copyright Holder that
186 are necessarily infringed by the Package. If you institute patent litigation
187 (including a cross-claim or counterclaim) against any party alleging that the
188 Package constitutes direct or contributory patent infringement,then this Artistic
189 License to you shall terminate on the date that such litigation is filed.
190  
191 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND
192 CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
193 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
194 NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS
195 REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
196 INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
197 OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
198  
199 =cut
200  
201 1; # End of Map::Tube::NYC
↑ Summary NYC/Line/BMTCanarsie.pm »