MapFeatures/Feature.pm

filter: Statementstmt 48.9% 24 / 49 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 77.7% 7 / 9 Podpod 50.0% 1 / 2 totaltotal 46.3% 32 / 69 CC 6 SCAR 29.3
CC
6
Cov
43%
new
42.0
stringify
2.0
BEGIN
1.0
CRAP 18.6
« MapFeatures/Feature/Value.pm ↑ Summary MapFeatures/Feature/Key.pm »
1 package Geo::OSM::MapFeatures::Feature;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Geo::OSM::MapFeatures::Feature::Key;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Geo::OSM::MapFeatures::Feature::Value;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Geo::OSM::MapFeatures::Feature::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use overload '""' => \&stringify;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use base qw(Class::Accessor);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 __PACKAGE__->mk_accessors(qw(key values types description));
14  
15 =head1 NAME
16  
17 Geo::OSM::MapFeatures::Feature - Represents a feature on map features
18  
19 =head1 VERSION
20  
21 Version 0.01
22  
23 =cut
24  
25 2 our $VERSION = '0.02';
26  
27  
28 =head1 SYNOPSIS
29  
30 A feature corresponds to one row on map features. It has a key, one or
31 more values, one or more feature types and a description.
32  
33 =head1 FUNCTIONS
34  
35 =head2 key
36  
37 =head2 values
38  
39 =head2 types
40  
41 Feature type: area, way or node
42  
43 =head2 description
44  
45 =cut
46  
47 0 ▶sub new {
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
48 0 my $pkg = shift;
49 0 ▶ my $class = ref $pkg || $pkg;
Condition0%0/3
ref $pkg || $pkg
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $pkg || $pkg
ref $pkg $pkg
Truth table0%0/3
A || B
A= ref $pkgB= $pkg
ABresult
1X1
011
000
50 0 my $self = bless( {}, $class);
51  
52 0 my $key = shift;
53 0 my $values = shift;
54 0 my @types = @{shift()};
55 0 my $description = shift;
56  
57 #
58 # Key
59 #
60  
61 0 $self->key( new Geo::OSM::MapFeatures::Feature::Key($key) );
62  
63 #
64 # Value
65 #
66  
67 # Hack for empty value list
68 0 ▶ if( @$values < 1 ){
Branch: 1 branch
BranchTrueFalseTotal
if (@$values < 1) 0 0 0
69 0 push( @$values, '' );
70 }
71  
72 0 foreach my $value ( @$values ){
73 0 push( @{$self->{values}}, new Geo::OSM::MapFeatures::Feature::Value($value) );
74 }
75  
76 #
77 # Types
78 #
79  
80 0 ▶ unless( @types ){
Branch: 1 branch
BranchTrueFalseTotal
unless (@types) 0 0 0
81 0 Carp::croak(sprintf("Trying to construct feature without element types. key=%s value(s)=%s", $self->key, join(' / ', @{$self->values})));
82 }
83 0 foreach my $type ( @types ){
84 #FIXME: use accessor instead
85 0 push( @{$self->{types}}, new Geo::OSM::MapFeatures::Feature::Type($type) );
86 }
87  
88 #
89 # Description
90 #
91  
92 0 $self->description($description);
93  
94 0 return $self;
95 }
96  
97 0 ▶sub stringify {
Subroutine stringify: not called CC=1 SCAR=6.9
Pod undocumented
98 0 my $self = shift;
99  
100 0 return sprintf("%s = %s", $self->{key}, join(' / ', @{ $self->{values} }));
101 }
102  
103 =head1 AUTHOR
104  
105 Knut Arne Bjørndal, C<< <bob at cakebox.net> >>
106  
107 =head1 BUGS
108  
109 Please report any bugs or feature requests to C<bug-geo-osm-mapfeatures-feature at rt.cpan.org>, or through
110 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Geo-OSM-MapFeatures>. I will be notified, and then you'll
111 automatically be notified of progress on your bug as I make changes.
112  
113  
114  
115  
116 =head1 SUPPORT
117  
118 You can find documentation for this module with the perldoc command.
119  
120 perldoc Geo::OSM::MapFeatures
121  
122  
123 You can also look for information at:
124  
125 =over 4
126  
127 =item * RT: CPAN's request tracker
128  
129 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Geo-OSM-MapFeatures>
130  
131 =item * AnnoCPAN: Annotated CPAN documentation
132  
133 L<http://annocpan.org/dist/Geo-OSM-MapFeatures>
134  
135 =item * CPAN Ratings
136  
137 L<http://cpanratings.perl.org/d/Geo-OSM-MapFeatures>
138  
139 =item * Search CPAN
140  
141 L<http://search.cpan.org/dist/Geo-OSM-MapFeatures>
142  
143 =back
144  
145  
146 =head1 ACKNOWLEDGEMENTS
147  
148  
149 =head1 COPYRIGHT & LICENSE
150  
151 Copyright 2008-2009 Knut Arne Bjørndal, all rights reserved.
152  
153 This program is free software; you can redistribute it and/or modify it
154 under the same terms as Perl itself.
155  
156  
157 =cut
158  
159 2 1; # End of Geo::OSM::MapFeatures::Feature
« MapFeatures/Feature/Value.pm ↑ Summary MapFeatures/Feature/Key.pm »