File Coverage

blib/lib/Algorithm/Metric/Chessboard/Journey.pm
Criterion Covered Total %
statement 24 24 100.0
branch 8 10 80.0
condition 1 2 50.0
subroutine 6 6 100.0
pod 1 5 20.0
total 40 47 85.1


line stmt bran cond sub pod time code
1 5     5   635 use strict;
  5         10  
  5         2053  
2             package Algorithm::Metric::Chessboard::Journey;
3              
4             =head1 NAME
5              
6             Algorithm::Metric::Chessboard::Journey - Model a journey on an Algorithm::Metric::Chessboard grid.
7              
8             =head1 DESCRIPTION
9              
10             See L.
11              
12             =head1 METHODS
13              
14             =over
15              
16             =item B
17              
18             my $wormhole_a =
19             Algorithm::Metric::Chessboard::Wormhole->new( x => 3, y => 9 );
20             my $wormhole_b =
21             Algorithm::Metric::Chessboard::Wormhole->new( x => 40, y => 70 );
22              
23             my $journey =
24             Algorithm::Metric::Chessboard::Journey->new(
25             start => [ 3, 10 ],
26             end => [ 45, 78 ],
27             via => [ $wormhole_a, $wormhole_b ],
28             distance => 10,
29             );
30              
31             This is purely a data object. You don't want to call this directly;
32             it's used internally by L.
33              
34             =cut
35              
36             sub new {
37 3     3 1 29 my ($class, %args) = @_;
38 3         7 my $self = {};
39 3         12 bless $self, $class;
40 3         14 $self->start( $args{start} );
41 3         11 $self->end( $args{end} );
42 3         10 $self->via( $args{via} );
43 3         23 $self->distance( $args{distance} );
44 3         16 return $self;
45             }
46              
47             sub start {
48 3     3 0 7 my ($self, $value) = @_;
49 3 50       23 $self->{start} = $value if $value;
50 3         7 return $self->{start};
51             }
52              
53             sub end {
54 3     3 0 7 my ($self, $value) = @_;
55 3 50       21 $self->{end} = $value if $value;
56 3         7 return $self->{end};
57             }
58              
59             sub via {
60 4     4 0 8 my ($self, $value) = @_;
61 4 100       14 $self->{via} = $value if $value;
62 4   50     15 my $via = $self->{via} || [];
63 4 100       15 return wantarray ? @$via : $via;
64             }
65              
66             sub distance {
67 5     5 0 857 my ($self, $value) = @_;
68 5 100       15 $self->{distance} = $value if $value;
69 5         22 return $self->{distance};
70             }
71              
72              
73             =back
74              
75             =head1 AUTHOR
76              
77             Kake Pugh (kake@earth.li).
78              
79             =head1 COPYRIGHT
80              
81             Copyright (C) 2004 Kake Pugh. All Rights Reserved.
82              
83             This module is free software; you can redistribute it and/or modify it
84             under the same terms as Perl itself.
85              
86             =cut
87              
88             1;