DBI/Primitive.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 57 CC 2 SCAR 10.6
CC
2
Cov
0%
_init_geo_osm_dbi_primitive
6.0
name
2.0
name_in_lang
2.0
CRAP 2.9
1 # Encoding and name #_{
2  
3 =encoding utf8
4 =head1 NAME
5  
6 Geo::OSM::DBI::Primitive - Base class for L<Geo::OSM::DBI::Primitive::Node>, L<Geo::OSM::DBI::Primitive::Way> and L<Geo::OSM::DBI::Primitive::Relation>.
7  
8 =cut
9 package Geo::OSM::DBI::Primitive;
10 #_}
11 #_{ use …
12 use warnings;
13 use strict;
14  
15 use utf8;
16 use Carp;
17  
18 use Geo::OSM::Primitive;
19 our @ISA=qw(Geo::OSM::Primitive);
20  
21 #_}
22 our $VERSION = 0.01;
23 #_{ Synopsis
24  
25 =head1 SYNOPSIS
26  
27 …
28  
29 =cut
30 #_}
31 #_{ Methods
32 #_{ Pod
33 =head1 METHODS
34 =cut
35 #_}
36 sub _init_geo_osm_dbi_primitive { #_{
37 #_{ POD
38  
39 =head2 _init_geo_osm_dbi_primitive
40  
41 my sth = $self->_init_geo_osm_dbi_primitive($osm_dbi);
42  
43 Initializes a derived class of C<<Geo::OSM::DBI::Primitive>> ( L<Geo::OSM::DBI::Primitive::Node>, L<Geo::OSM::DBI::Primitive::Way> and L<Geo::OSM::DBI::Primitive::Relation>).
44  
45 This is necessary because these derived classes use multiple inheritance.
46  
47 C<< $osm_dbi >> must be a L<<Geo::OSM::DBI>>.
48  
49 =cut
50  
51 #_}
52
53 my $self = shift;
54 my $osm_dbi = shift;
55  
56 croak "Need Geo::OSM::DBI" unless ref $osm_dbi and $osm_dbi->isa('Geo::OSM::DBI');
57 $self->{osm_dbi} = $osm_dbi;
58  
59 } #_}
60 sub name { #_{
61 #_{ POD
62  
63 =head2 name
64  
65 my $name = $rel->name();
66  
67 Returns the name of the object;
68  
69 =cut
70  
71 #_}
72  
73 my $self = shift;
74  
75 my $sth = $self->{osm_dbi}->_sth_prepare_name($self->primitive_type());
76 $sth->execute($self->{id}) or die;
77  
78 my ($name) = $sth->fetchrow_array;
79  
80 return $name;
81  
82 } #_}
83 sub name_in_lang { #_{
84 #_{ POD
85  
86 =head2 name_in_lang
87  
88 my $lang = 'de'; # or 'en' or 'fr' or 'it' or …
89 my $name = $rel->name_in_lang($lang);
90  
91 Returns the name of the object in the language C<$lang>.
92  
93 =cut
94  
95 #_}
96  
97 my $self = shift;
98 my $lang = shift;
99  
100 my $sth = $self->{osm_dbi}->_sth_prepare_name_in_lang('rel');
101 $sth->execute($self->{id}, "name:$lang") or die;
102  
103 my ($name) = $sth->fetchrow_array;
104  
105 return $name;
106  
107 } #_}
108 #q sub _sth_prepare_name { #_{
109 #q #_{ POD
110 #q
111 #q =head2 _sth_prepare_name
112 #q
113 #q my sth = $self->_sth_prepare_name($primitive_type);
114 #q
115 #q Prepares the statement handle to get the name for a primitive. C<$primitive_type> must be C<node>, C<way> or C<relation>.
116 #q
117 #q =cut
118 #q
119 #q #_}
120 #q
121 #q my $self = shift;
122 #q my $primitive_type = shift;
123 #q # my $class = shift;
124 #q # my $id = shift;
125 #q
126 #q # my $self = $class->SUPER::new($id);
127 #q # croak "not a Geo::OSM::DBI::Primitive::Relation" unless $self -> isa('Geo::OSM::DBI::Primitive::Relation');
128 #q
129 #q return $self;
130 #q
131 #q } #_}
132 #_}
133  
134 'tq84';