File Coverage

blib/lib/Locale/Geocode/Division.pm
Criterion Covered Total %
statement 9 32 28.1
branch 0 6 0.0
condition 0 6 0.0
subroutine 3 14 21.4
pod 10 10 100.0
total 22 68 32.3


line stmt bran cond sub pod time code
1             package Locale::Geocode::Division;
2              
3 1     1   5 use warnings;
  1         2  
  1         103  
4 1     1   5 use strict;
  1         2  
  1         66  
5              
6             =head1 NAME
7              
8             Locale::Geocode::Division
9              
10             =head1 DESCRIPTION
11              
12             Locale::Geocode::Division provides methods for
13             accessing information regarding administrative
14             divisions within territories as defined by
15             ISO-3166-2.
16              
17             =head1 SYNOPSIS
18              
19             my $lct = new Locale::Geocode::Division 'US';
20              
21             # lookup a subdivision of US
22             my $lcd = $lct->lookup('TN');
23              
24             # retrieve ISO-3166-2 information for US-TN
25             my $name = $lcd->name; # Tennessee
26             my $code = $lcd->code; # TN
27              
28             # returns an array of Locale::Geocode::Division
29             # objects representing all divisions of US
30             my @divs = $lct->divisions;
31              
32             =cut
33              
34 1     1   5 use overload '""' => sub { return shift->code };
  1     0   2  
  1         9  
  0            
35              
36             our @meta = qw(name code fips region has_notes num_notes);
37              
38             =head1 METHODS
39              
40             =over 4
41              
42             =item new
43              
44             =cut
45              
46             sub new
47             {
48 0     0 1   my $proto = shift;
49 0           my $key = lc(shift);
50 0           my $lct = shift;
51              
52 0   0       my $class = ref($proto) || $proto;
53 0           my $self = {};
54              
55 0           $self->{territory} = $lct;
56              
57 0   0       $self->{data} = $lct->{data}->{divs_code}->{$key} ||
58             $lct->{data}->{divs_fips}->{$key} ||
59             $lct->{data}->{divs_name}->{$key};
60              
61 0 0         return undef if not defined $self->{data};
62 0 0         return undef if not $lct->lg->chkext($self->{data});
63              
64 0           return bless $self, $class;
65             }
66              
67             =item name
68              
69             =cut
70              
71 0     0 1   sub name { return shift->{data}->{name} }
72              
73             =item code
74              
75             =cut
76              
77 0     0 1   sub code { return shift->{data}->{code} }
78              
79             =item fips
80              
81             =cut
82              
83 0     0 1   sub fips { return shift->{data}->{fips} }
84              
85             =item region
86              
87             =cut
88              
89 0     0 1   sub region { return shift->{data}->{region} }
90              
91             =item parent
92              
93             =cut
94              
95 0     0 1   sub parent { return shift->{territory} }
96              
97             =item has_notes
98              
99             =cut
100              
101 0 0   0 1   sub has_notes { return scalar @{ shift->{notes} } > 0 ? 1 : 0 }
  0            
102              
103             =item num_notes
104              
105             =cut
106              
107 0     0 1   sub num_notes { return scalar @{ shift->{notes} } }
  0            
108              
109             =item notes
110              
111             =cut
112              
113 0     0 1   sub notes { return @{ shift->{notes} } }
  0            
114              
115             =item note
116              
117             =cut
118              
119 0     0 1   sub note { return shift->{notes}->[shift] }
120              
121             =back
122              
123             =head1 AUTHOR
124              
125             Mike Eldridge
126              
127             =head1 CREDITS
128              
129             Kim Ryan
130              
131             =head1 SEE ALSO
132              
133             L
134             L
135              
136             =cut
137              
138             1;