File Coverage

blib/lib/SecondLife/Vector.pm
Criterion Covered Total %
statement 21 23 91.3
branch 3 4 75.0
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 32 35 91.4


line stmt bran cond sub pod time code
1             package SecondLife::Vector;
2             {
3             $SecondLife::Vector::VERSION = '0.900';
4             }
5             # ABSTRACT: Second Life's vectors (an x, y and z representing a location );
6 2     2   2721 use Any::Moose;
  2         79544  
  2         14  
7 2     2   3768 use Regexp::Common qw/ RE_num_real /;
  2         2659  
  2         15  
8              
9             has [qw(x y z)] => (is=>'rw', isa=>'Num');
10 2     2   73168 use overload q{""} => \&stringify;
  2         5  
  2         27  
11              
12             sub BUILDARGS {
13 3     3 1 961 my $self = shift;
14 3 100       10 if ( @_ == 1 ) {
15 2         5 my( $vec ) = @_;
16 2         9 my $num = RE_num_real();
17 2 50       415 if ( $vec =~ /^ [(<] \s* ($num), \s* ($num), \s* ($num) \s* [)>] $/xo ) {
18 2         47 return { x=> $1, y=> $2, z=> $3 };
19             }
20             else {
21 0         0 require Carp;
22 0         0 Carp::croak( "Could not parse a vector from $vec" );
23             }
24             }
25             else {
26 1         9 return { @_ };
27             }
28             }
29              
30             sub stringify {
31 4     4 1 129 my $self = shift;
32 4         59 return "<".join(", ",$self->x,$self->y,$self->z).">";
33             }
34              
35 2     2   521 no Any::Moose;
  2         6  
  2         16  
36             __PACKAGE__->meta->make_immutable;
37              
38             1;
39              
40              
41             __END__