| 1 | package Map::Tube::Node; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use version; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | our $VERSION = qv('v5.2.0'); | ||
| 8 | our $AUTHORITY = 'cpan:MANWAR'; | ||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | Map::Tube::Node - Class to represent the station in the map. | ||
| 13 | |||
| 14 | =head1 VERSION | ||
| 15 | |||
| 16 | Version v5.2.0 | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | 1 | ▶ | use v5.14; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | 1 | ▶ | use Data::Dumper; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 22 | 1 | ▶ | use Map::Tube::Types qw(Lines Nodes); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | |||
| 24 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 25 | 1 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 26 | |||
| 27 | 1 | ▶ | use overload q{""} => 'as_string', fallback => 1; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 28 | |||
| 29 | has id => (is => 'ro', required => 1); | ||
| 30 | has name => (is => 'ro', required => 1); | ||
| 31 | has link => (is => 'ro', required => 1); | ||
| 32 | has links => (is => 'ro', isa => Nodes); | ||
| 33 | has line => (is => 'rw', isa => Lines, required => 1); | ||
| 34 | with 'Map::Tube::Plugin::Formatter'; | ||
| 35 | |||
| 36 | 0 | ▶ | sub as_string { |
|
Subroutine
as_string: not called CC=1 SCAR=6.9
| |||
| 37 | 0 | my ($self) = @_; | |
| 38 | |||
| 39 | 0 | my $line = join ', ', @{$self->line}; | |
| 40 | 0 | return sprintf("%s (%s)", $self->name, $line); | |
| 41 | } | ||
| 42 | |||
| 43 | =head1 DESCRIPTION | ||
| 44 | |||
| 45 | It provides simple interface to the C<node> of the map. | ||
| 46 | |||
| 47 | =head1 SYNOPSIS | ||
| 48 | |||
| 49 | use strict; use warnings; | ||
| 50 | use Map::Tube::Node; | ||
| 51 | |||
| 52 | my $line = Map::Tube::Line->new({ id => 1, name => 'L1', color => 'red' }); | ||
| 53 | my $node = Map::Tube::Node->new({ id => 1, name => 'N1', link => '2,3', line => [$line] }); | ||
| 54 | |||
| 55 | print "Station:", $node, "\n"; | ||
| 56 | print "Station Id:", $node->id, "\n"; | ||
| 57 | print "Station Name:", $node->name, "\n"; | ||
| 58 | print "Station Link:", $node->link, "\n"; | ||
| 59 | print "Station Line:", $node->line, "\n"; | ||
| 60 | print "Station Links:", $node->links, "\n"; | ||
| 61 | |||
| 62 | =head1 CONSTRUCTOR | ||
| 63 | |||
| 64 | The following possible attributes for an object of type L<Map::Tube::Node>. | ||
| 65 | |||
| 66 | +-------+------------------------------------------------------------------+ | ||
| 67 | | Key | Description | | ||
| 68 | +-------+------------------------------------------------------------------+ | ||
| 69 | | id | Unique Node ID (required). | | ||
| 70 | | name | Node name (required). | | ||
| 71 | | link | Comma separated Node ID (required). | | ||
| 72 | | links | Ref to a list of objects of type Map::Tube::Node (optional). | | ||
| 73 | | line | Ref to a list of objects of type Map::Tube::Line (required). | | ||
| 74 | +-------+------------------------------------------------------------------+ | ||
| 75 | |||
| 76 | =head1 METHODS | ||
| 77 | |||
| 78 | =head2 id() | ||
| 79 | |||
| 80 | Returns the station id. | ||
| 81 | |||
| 82 | =head2 name() | ||
| 83 | |||
| 84 | Returns the station name. | ||
| 85 | |||
| 86 | =head2 link() | ||
| 87 | |||
| 88 | Returns comma separated linked station id. | ||
| 89 | |||
| 90 | =head2 links() | ||
| 91 | |||
| 92 | Returns ref to a list of objects of type L<Map::Tube::Node>. | ||
| 93 | |||
| 94 | =head2 line() | ||
| 95 | |||
| 96 | Returns ref to a list of objects of type L<Map::Tube::Line>. | ||
| 97 | |||
| 98 | =head1 AUTHOR | ||
| 99 | |||
| 100 | Mohammad Sajid Anwar, C<< <mohammad.anwar at yahoo.com> >> | ||
| 101 | |||
| 102 | =head1 REPOSITORY | ||
| 103 | |||
| 104 | L<https://github.com/manwar/Map-Tube> | ||
| 105 | |||
| 106 | =head1 BUGS | ||
| 107 | |||
| 108 | Please report any bugs or feature requests through the web interface at L<https://github.com/manwar/Map-Tube/issues>. | ||
| 109 | I will be notified and then you'll automatically be notified of progress on your | ||
| 110 | bug as I make changes. | ||
| 111 | |||
| 112 | =head1 SUPPORT | ||
| 113 | |||
| 114 | You can find documentation for this module with the perldoc command. | ||
| 115 | |||
| 116 | perldoc Map::Tube::Node | ||
| 117 | |||
| 118 | You can also look for information at: | ||
| 119 | |||
| 120 | =over 4 | ||
| 121 | |||
| 122 | =item * BUG Report | ||
| 123 | |||
| 124 | L<https://github.com/manwar/Map-Tube/issues> | ||
| 125 | |||
| 126 | =item * Search MetaCPAN | ||
| 127 | |||
| 128 | L<https://metacpan.org/dist/Map-Tube/> | ||
| 129 | |||
| 130 | =back | ||
| 131 | |||
| 132 | =head1 LICENSE AND COPYRIGHT | ||
| 133 | |||
| 134 | Copyright (C) 2010 - 2026 Mohammad Sajid Anwar. | ||
| 135 | |||
| 136 | This program is free software;you can redistribute it and/or modify it under the | ||
| 137 | terms of the the Artistic License(2.0). You may obtain a copy of the full license | ||
| 138 | at: | ||
| 139 | |||
| 140 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||
| 141 | |||
| 142 | Any use, modification, and distribution of the Standard or Modified Versions is | ||
| 143 | governed by this Artistic License.By using, modifying or distributing the Package, | ||
| 144 | you accept this license. Do not use, modify, or distribute the Package, if you do | ||
| 145 | not accept this license. | ||
| 146 | |||
| 147 | If your Modified Version has been derived from a Modified Version made by someone | ||
| 148 | other than you,you are nevertheless required to ensure that your Modified Version | ||
| 149 | complies with the requirements of this license. | ||
| 150 | |||
| 151 | This license does not grant you the right to use any trademark, service mark, | ||
| 152 | tradename, or logo of the Copyright Holder. | ||
| 153 | |||
| 154 | This license includes the non-exclusive, worldwide, free-of-charge patent license | ||
| 155 | to make, have made, use, offer to sell, sell, import and otherwise transfer the | ||
| 156 | Package with respect to any patent claims licensable by the Copyright Holder that | ||
| 157 | are necessarily infringed by the Package. If you institute patent litigation | ||
| 158 | (including a cross-claim or counterclaim) against any party alleging that the | ||
| 159 | Package constitutes direct or contributory patent infringement,then this Artistic | ||
| 160 | License to you shall terminate on the date that such litigation is filed. | ||
| 161 | |||
| 162 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND | ||
| 163 | CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED | ||
| 164 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR | ||
| 165 | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS | ||
| 166 | REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, | ||
| 167 | INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE | ||
| 168 | OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 169 | |||
| 170 | =cut | ||
| 171 | |||
| 172 | 1; # End of Map::Tube::Node | ||