TigerLine/Record/4.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 41 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Geo::TigerLine::Record::4;
2  
3 use strict;
4  
5 use Carp::Assert;
6 use base qw(Geo::TigerLine::Record::Parser Geo::TigerLine::Record::Accessor
7 Geo::TigerLine::Record Class::Data::Inheritable);
8  
9 use vars qw($VERSION);
10 $VERSION = '0.03';
11  
12  
13 # Auto-generated data dictionary.
14 my %Data_Dict = (
15 'feat1' => {
16 'len' => 8,
17 'beg' => 19,
18 'bv' => 'No',
19 'fieldnum' => 5,
20 'type' => 'N',
21 'description' => 'Line Additional Name Identification Number, First',
22 'end' => 26,
23 'fmt' => 'R',
24 'field' => 'feat1'
25 },
26 'version' => {
27 'len' => 4,
28 'beg' => 2,
29 'bv' => 'No',
30 'fieldnum' => 2,
31 'type' => 'N',
32 'description' => 'Version Number',
33 'end' => 5,
34 'fmt' => 'L',
35 'field' => 'version'
36 },
37 'feat3' => {
38 'len' => 8,
39 'beg' => 35,
40 'bv' => 'Yes',
41 'fieldnum' => 7,
42 'type' => 'N',
43 'description' => 'Line Additional Name Identification Number, Third',
44 'end' => 42,
45 'fmt' => 'R',
46 'field' => 'feat3'
47 },
48 'tlid' => {
49 'len' => 10,
50 'beg' => 6,
51 'bv' => 'No',
52 'fieldnum' => 3,
53 'type' => 'N',
54 'description' => 'TIGER/Line ID, Permanent 1-Cell Number',
55 'end' => 15,
56 'fmt' => 'R',
57 'field' => 'tlid'
58 },
59 'feat4' => {
60 'len' => 8,
61 'beg' => 43,
62 'bv' => 'Yes',
63 'fieldnum' => 8,
64 'type' => 'N',
65 'description' => 'Line Additional Name Identification Number, Fourth',
66 'end' => 50,
67 'fmt' => 'R',
68 'field' => 'feat4'
69 },
70 'rtsq' => {
71 'len' => 3,
72 'beg' => 16,
73 'bv' => 'No',
74 'fieldnum' => 4,
75 'type' => 'N',
76 'description' => 'Record Sequence Number',
77 'end' => 18,
78 'fmt' => 'R',
79 'field' => 'rtsq'
80 },
81 'feat5' => {
82 'len' => 8,
83 'beg' => 51,
84 'bv' => 'Yes',
85 'fieldnum' => 9,
86 'type' => 'N',
87 'description' => 'Line Additional Name Identification Number, Fifth',
88 'end' => 58,
89 'fmt' => 'R',
90 'field' => 'feat5'
91 },
92 'rt' => {
93 'len' => 1,
94 'beg' => 1,
95 'bv' => 'No',
96 'fieldnum' => 1,
97 'type' => 'A',
98 'description' => 'Record Type',
99 'end' => 1,
100 'fmt' => 'L',
101 'field' => 'rt'
102 },
103 'feat2' => {
104 'len' => 8,
105 'beg' => 27,
106 'bv' => 'Yes',
107 'fieldnum' => 6,
108 'type' => 'N',
109 'description' => 'Line Additional Name Identification Number, Second',
110 'end' => 34,
111 'fmt' => 'R',
112 'field' => 'feat2'
113 }
114 );
115  
116  
117 my @Data_Fields = (
118 'rt',
119 'version',
120 'tlid',
121 'rtsq',
122 'feat1',
123 'feat2',
124 'feat3',
125 'feat4',
126 'feat5'
127 );
128  
129  
130 assert(keys %Data_Dict == @Data_Fields);
131  
132 # Turn the data dictionary into class data
133 __PACKAGE__->mk_classdata('Fields');
134 __PACKAGE__->mk_classdata('Dict');
135 __PACKAGE__->mk_classdata('Pack_Tmpl');
136  
137 __PACKAGE__->Dict(\%Data_Dict);
138 __PACKAGE__->Fields(\@Data_Fields);
139  
140 # Generate a pack template for parsing and turn it into class data.
141 my $pack_tmpl = join ' ', map { "A$_" } map { $_->{len} }
142 @Data_Dict{@Data_Fields};
143 __PACKAGE__->Pack_Tmpl($pack_tmpl);
144  
145 # Generate accessors for each data field
146 foreach my $def (@Data_Dict{@Data_Fields}) {
147 __PACKAGE__->mk_accessor($def);
148 }
149  
150  
151 =pod
152  
153 =head1 NAME
154  
155 Geo::TigerLine::Record::4 - TIGER/Line 2006 Index to Alternative Feature Identifiers
156  
157 =head1 SYNOPSIS
158  
159 use Geo::TigerLine::Record::4;
160  
161 @records = Geo::TigerLine::Record::4->parse_file($fh);
162 @records = Geo::TigerLine::Record::4->parse_file($fh, \&callback);
163  
164 $record = Geo::TigerLine::Record::4->new(\%fields);
165  
166 $record->rt();
167 $record->version();
168 $record->tlid();
169 $record->rtsq();
170 $record->feat1();
171 $record->feat2();
172 $record->feat3();
173 $record->feat4();
174 $record->feat5();
175  
176  
177 =head1 DESCRIPTION
178  
179 This is a class representing record type 4 of the TIGER/Line 2006
180 census geographic database. Each object is one record. It also
181 contains methods to parse TIGER/Line record type 4 files and turn them
182 into objects.
183  
184 This is intended as an intermediate format between pulling the raw
185 data out of the simplistic TIGER/Line data files into something more
186 sophisticated (a process you should only have to do once). As such,
187 it's not very fast, but its careful, easy to use and performs some
188 verifications on the data being read.
189  
190 As this class is autogenerated by mk_parsers, think before you modify this
191 file. It's OO, so consider sub-classing instead.
192  
193  
194 =head2 Accessors
195  
196 These are simple get/set accessors for each field of a record
197 generated from the TIGER/Line 2006 data dictionary. They perform some
198 data validation.
199  
200 =over 4
201  
202 =item B<rt>
203  
204 $data = $record->rt();
205 $record->rt($data);
206  
207 Record Type.
208  
209 Expects alphanumeric data of no more than 1 characters. $data cannot be blank
210 and should be left justified.
211  
212  
213 =item B<version>
214  
215 $data = $record->version();
216 $record->version($data);
217  
218 Version Number.
219  
220 Expects numeric data of no more than 4 characters. $data cannot be blank
221 and should be left justified.
222  
223  
224 =item B<tlid>
225  
226 $data = $record->tlid();
227 $record->tlid($data);
228  
229 TIGER/Line ID, Permanent 1-Cell Number.
230  
231 Expects numeric data of no more than 10 characters. $data cannot be blank
232 and should be right justified.
233  
234  
235 =item B<rtsq>
236  
237 $data = $record->rtsq();
238 $record->rtsq($data);
239  
240 Record Sequence Number.
241  
242 Expects numeric data of no more than 3 characters. $data cannot be blank
243 and should be right justified.
244  
245  
246 =item B<feat1>
247  
248 $data = $record->feat1();
249 $record->feat1($data);
250  
251 Line Additional Name Identification Number, First.
252  
253 Expects numeric data of no more than 8 characters. $data cannot be blank
254 and should be right justified.
255  
256  
257 =item B<feat2>
258  
259 $data = $record->feat2();
260 $record->feat2($data);
261  
262 Line Additional Name Identification Number, Second.
263  
264 Expects numeric data of no more than 8 characters. $data can be blank
265 and should be right justified.
266  
267  
268 =item B<feat3>
269  
270 $data = $record->feat3();
271 $record->feat3($data);
272  
273 Line Additional Name Identification Number, Third.
274  
275 Expects numeric data of no more than 8 characters. $data can be blank
276 and should be right justified.
277  
278  
279 =item B<feat4>
280  
281 $data = $record->feat4();
282 $record->feat4($data);
283  
284 Line Additional Name Identification Number, Fourth.
285  
286 Expects numeric data of no more than 8 characters. $data can be blank
287 and should be right justified.
288  
289  
290 =item B<feat5>
291  
292 $data = $record->feat5();
293 $record->feat5($data);
294  
295 Line Additional Name Identification Number, Fifth.
296  
297 Expects numeric data of no more than 8 characters. $data can be blank
298 and should be right justified.
299  
300  
301  
302 =back
303  
304  
305 =head2 Data dictionary
306  
307 This is the original TIGER/Line 2006 data dictionary from which this
308 class was generated.
309  
310 Record Type 4 - Index to Alternative Feature Identifiers
311
312 Field BV Fmt Type Beg End Len Description
313 RT No L A 1 1 1 Record Type
314 VERSION No L N 2 5 4 Version Number
315 TLID No R N 6 15 10 TIGER/Line ID, Permanent 1-Cell Number
316 RTSQ No R N 16 18 3 Record Sequence Number
317 FEAT1 No R N 19 26 8 Line Additional Name Identification Number, First
318 FEAT2 Yes R N 27 34 8 Line Additional Name Identification Number, Second
319 FEAT3 Yes R N 35 42 8 Line Additional Name Identification Number, Third
320 FEAT4 Yes R N 43 50 8 Line Additional Name Identification Number, Fourth
321 FEAT5 Yes R N 51 58 8 Line Additional Name Identification Number, Fifth
322  
323  
324  
325 =head1 AUTHOR
326  
327 Michael G Schwern <schwern@pobox.com>
328  
329 =head1 SEE ALSO
330  
331 L<Geo::TigerLine>, L<mk_parsers>
332  
333 =cut
334  
335  
336 return 'Honey flash!';