fips_lookup 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile +1 -9
- data/Gemfile.lock +61 -38
- data/README.md +10 -10
- data/lib/data/county/AK.csv +30 -29
- data/lib/data/county/AL.csv +67 -67
- data/lib/data/county/AR.csv +75 -75
- data/lib/data/county/AS.csv +5 -5
- data/lib/data/county/AZ.csv +15 -15
- data/lib/data/county/CA.csv +58 -58
- data/lib/data/county/CO.csv +64 -64
- data/lib/data/county/CT.csv +8 -8
- data/lib/data/county/DC.csv +1 -1
- data/lib/data/county/DE.csv +3 -3
- data/lib/data/county/FL.csv +67 -67
- data/lib/data/county/GA.csv +159 -159
- data/lib/data/county/GU.csv +1 -1
- data/lib/data/county/HI.csv +5 -5
- data/lib/data/county/IA.csv +99 -99
- data/lib/data/county/ID.csv +44 -44
- data/lib/data/county/IL.csv +102 -102
- data/lib/data/county/IN.csv +92 -92
- data/lib/data/county/KS.csv +105 -105
- data/lib/data/county/KY.csv +120 -120
- data/lib/data/county/LA.csv +64 -64
- data/lib/data/county/MA.csv +14 -14
- data/lib/data/county/MD.csv +24 -24
- data/lib/data/county/ME.csv +16 -16
- data/lib/data/county/MI.csv +83 -83
- data/lib/data/county/MN.csv +87 -87
- data/lib/data/county/MO.csv +115 -115
- data/lib/data/county/MP.csv +4 -4
- data/lib/data/county/MS.csv +82 -82
- data/lib/data/county/MT.csv +56 -56
- data/lib/data/county/NC.csv +100 -100
- data/lib/data/county/ND.csv +53 -53
- data/lib/data/county/NE.csv +93 -93
- data/lib/data/county/NH.csv +10 -10
- data/lib/data/county/NJ.csv +21 -21
- data/lib/data/county/NM.csv +33 -33
- data/lib/data/county/NV.csv +17 -17
- data/lib/data/county/NY.csv +62 -62
- data/lib/data/county/OH.csv +88 -88
- data/lib/data/county/OK.csv +77 -77
- data/lib/data/county/OR.csv +36 -36
- data/lib/data/county/PA.csv +67 -67
- data/lib/data/county/PR.csv +78 -78
- data/lib/data/county/RI.csv +5 -5
- data/lib/data/county/SC.csv +46 -46
- data/lib/data/county/SD.csv +66 -66
- data/lib/data/county/TN.csv +95 -95
- data/lib/data/county/TX.csv +254 -254
- data/lib/data/county/UM.csv +1 -1
- data/lib/data/county/UT.csv +29 -29
- data/lib/data/county/VA.csv +133 -134
- data/lib/data/county/VI.csv +3 -3
- data/lib/data/county/VT.csv +14 -14
- data/lib/data/county/WA.csv +39 -39
- data/lib/data/county/WI.csv +72 -72
- data/lib/data/county/WV.csv +55 -55
- data/lib/data/county/WY.csv +23 -23
- data/lib/data/state.csv +1 -1
- data/lib/data/subdivision/AK.csv +37 -0
- data/lib/data/subdivision/AL.csv +390 -0
- data/lib/data/subdivision/AR.csv +1210 -0
- data/lib/data/subdivision/AS.csv +16 -0
- data/lib/data/subdivision/AZ.csv +80 -0
- data/lib/data/subdivision/CA.csv +404 -0
- data/lib/data/subdivision/CO.csv +209 -0
- data/lib/data/subdivision/CT.csv +173 -0
- data/lib/data/subdivision/DC.csv +1 -0
- data/lib/data/subdivision/DE.csv +27 -0
- data/lib/data/subdivision/FL.csv +316 -0
- data/lib/data/subdivision/GA.csv +586 -0
- data/lib/data/subdivision/GU.csv +20 -0
- data/lib/data/subdivision/HI.csv +44 -0
- data/lib/data/subdivision/IA.csv +1662 -0
- data/lib/data/subdivision/ID.csv +170 -0
- data/lib/data/subdivision/IL.csv +1708 -0
- data/lib/data/subdivision/IN.csv +1012 -0
- data/lib/data/subdivision/KS.csv +1531 -0
- data/lib/data/subdivision/KY.csv +493 -0
- data/lib/data/subdivision/LA.csv +576 -0
- data/lib/data/subdivision/MA.csv +357 -0
- data/lib/data/subdivision/MD.csv +290 -0
- data/lib/data/subdivision/ME.csv +530 -0
- data/lib/data/subdivision/MI.csv +1579 -0
- data/lib/data/subdivision/MN.csv +2761 -0
- data/lib/data/subdivision/MO.csv +1394 -0
- data/lib/data/subdivision/MP.csv +12 -0
- data/lib/data/subdivision/MS.csv +410 -0
- data/lib/data/subdivision/MT.csv +194 -0
- data/lib/data/subdivision/NC.csv +1041 -0
- data/lib/data/subdivision/ND.csv +1762 -0
- data/lib/data/subdivision/NE.csv +1193 -0
- data/lib/data/subdivision/NH.csv +260 -0
- data/lib/data/subdivision/NJ.csv +570 -0
- data/lib/data/subdivision/NM.csv +130 -0
- data/lib/data/subdivision/NV.csv +71 -0
- data/lib/data/subdivision/NY.csv +1023 -0
- data/lib/data/subdivision/OH.csv +1606 -0
- data/lib/data/subdivision/OK.csv +305 -0
- data/lib/data/subdivision/OR.csv +212 -0
- data/lib/data/subdivision/PA.csv +2573 -0
- data/lib/data/subdivision/PR.csv +939 -0
- data/lib/data/subdivision/RI.csv +40 -0
- data/lib/data/subdivision/SC.csv +299 -0
- data/lib/data/subdivision/SD.csv +1331 -0
- data/lib/data/subdivision/TN.csv +844 -0
- data/lib/data/subdivision/TX.csv +862 -0
- data/lib/data/subdivision/UM.csv +1 -0
- data/lib/data/subdivision/UT.csv +93 -0
- data/lib/data/subdivision/VA.csv +552 -0
- data/lib/data/subdivision/VI.csv +23 -0
- data/lib/data/subdivision/VT.csv +255 -0
- data/lib/data/subdivision/WA.csv +242 -0
- data/lib/data/subdivision/WI.csv +1922 -0
- data/lib/data/subdivision/WV.csv +228 -0
- data/lib/data/subdivision/WY.csv +71 -0
- data/lib/fips_lookup/county.rb +65 -0
- data/lib/fips_lookup/state.rb +46 -0
- data/lib/fips_lookup/subdivision.rb +48 -0
- data/lib/fips_lookup/version.rb +1 -1
- data/lib/fips_lookup.rb +7 -73
- metadata +94 -10
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
WV,54,001,Barbour County,92328,01928323,North district,Z1,N
|
|
2
|
+
WV,54,001,Barbour County,92892,01928358,South district,Z1,N
|
|
3
|
+
WV,54,001,Barbour County,93588,01928406,West district,Z1,N
|
|
4
|
+
WV,54,003,Berkeley County,90006,01928161,Adam Stephens district,Z1,N
|
|
5
|
+
WV,54,003,Berkeley County,92322,01928322,Norborne district,Z1,N
|
|
6
|
+
WV,54,003,Berkeley County,92526,01928342,Potomac district,Z1,N
|
|
7
|
+
WV,54,003,Berkeley County,92754,01928353,Shenandoah district,Z1,N
|
|
8
|
+
WV,54,003,Berkeley County,93171,01928382,Tuscarora district,Z1,N
|
|
9
|
+
WV,54,003,Berkeley County,93388,01928394,Valley district,Z1,N
|
|
10
|
+
WV,54,005,Boone County,90762,01928204,District 1,Z1,N
|
|
11
|
+
WV,54,005,Boone County,90796,01928215,District 2,Z1,N
|
|
12
|
+
WV,54,005,Boone County,90832,01928226,District 3,Z1,N
|
|
13
|
+
WV,54,007,Braxton County,90968,01928262,Eastern district,Z1,N
|
|
14
|
+
WV,54,007,Braxton County,92346,01928330,Northern district,Z1,N
|
|
15
|
+
WV,54,007,Braxton County,92922,01928366,Southern district,Z1,N
|
|
16
|
+
WV,54,007,Braxton County,93597,01928413,Western district,Z1,N
|
|
17
|
+
WV,54,009,Brooke County,91104,01928271,Follansbee district,Z1,N
|
|
18
|
+
WV,54,009,Brooke County,93552,01928403,Weirton district,Z1,N
|
|
19
|
+
WV,54,009,Brooke County,93564,01928404,Wellsburg district,Z1,N
|
|
20
|
+
WV,54,011,Cabell County,90764,01928205,District 1,Z1,N
|
|
21
|
+
WV,54,011,Cabell County,90798,01928216,District 2,Z1,N
|
|
22
|
+
WV,54,011,Cabell County,90834,01928227,District 3,Z1,N
|
|
23
|
+
WV,54,011,Cabell County,90870,01928237,District 4,Z1,N
|
|
24
|
+
WV,54,011,Cabell County,90882,01928241,District 5,Z1,N
|
|
25
|
+
WV,54,013,Calhoun County,90766,01928206,District 1,Z1,N
|
|
26
|
+
WV,54,013,Calhoun County,90800,01928217,District 2,Z1,N
|
|
27
|
+
WV,54,013,Calhoun County,90836,01928228,District 3,Z1,N
|
|
28
|
+
WV,54,013,Calhoun County,90873,01928238,District 4,Z1,N
|
|
29
|
+
WV,54,013,Calhoun County,90885,01928242,District 5,Z1,N
|
|
30
|
+
WV,54,015,Clay County,90891,01928244,District A,Z1,N
|
|
31
|
+
WV,54,015,Clay County,90893,01928246,District B,Z1,N
|
|
32
|
+
WV,54,015,Clay County,90895,01928248,District C,Z1,N
|
|
33
|
+
WV,54,017,Doddridge County,90138,01928165,Beech district,Z1,N
|
|
34
|
+
WV,54,017,Doddridge County,92094,01928309,Maple district,Z1,N
|
|
35
|
+
WV,54,017,Doddridge County,92374,01928333,Oak district,Z1,N
|
|
36
|
+
WV,54,017,Doddridge County,92466,01928337,Pine district,Z1,N
|
|
37
|
+
WV,54,019,Fayette County,92280,01928319,New Haven district,Z1,N
|
|
38
|
+
WV,54,019,Fayette County,92472,01928338,Plateau district,Z1,N
|
|
39
|
+
WV,54,019,Fayette County,93396,01928396,Valley district,Z1,N
|
|
40
|
+
WV,54,021,Gilmer County,90408,01928180,Center district,Z1,N
|
|
41
|
+
WV,54,021,Gilmer County,90534,01928191,City district,Z1,N
|
|
42
|
+
WV,54,021,Gilmer County,90758,01928203,De Kalb-Troy district,Z1,N
|
|
43
|
+
WV,54,021,Gilmer County,91236,01928274,Glenville district,Z1,N
|
|
44
|
+
WV,54,023,Grant County,91296,01928277,Grant district,Z1,N
|
|
45
|
+
WV,54,023,Grant County,92208,01928315,Milroy district,Z1,N
|
|
46
|
+
WV,54,023,Grant County,93216,01928385,Union district,Z1,N
|
|
47
|
+
WV,54,025,Greenbrier County,90449,01928181,Central district,Z1,N
|
|
48
|
+
WV,54,025,Greenbrier County,90972,01928256,Eastern district,Z1,N
|
|
49
|
+
WV,54,025,Greenbrier County,93601,01928408,Western district,Z1,N
|
|
50
|
+
WV,54,027,Hampshire County,90204,01928169,Bloomery district,Z1,N
|
|
51
|
+
WV,54,027,Hampshire County,90360,01928177,Capon district,Z1,N
|
|
52
|
+
WV,54,027,Hampshire County,91248,01928275,Gore district,Z1,N
|
|
53
|
+
WV,54,027,Hampshire County,92184,01928314,Mill Creek district,Z1,N
|
|
54
|
+
WV,54,027,Hampshire County,92676,01928347,Romney district,Z1,N
|
|
55
|
+
WV,54,027,Hampshire County,92820,01928356,Sherman district,Z1,N
|
|
56
|
+
WV,54,027,Hampshire County,92988,01928369,Springfield district,Z1,N
|
|
57
|
+
WV,54,029,Hancock County,90312,01928175,Butler district,Z1,N
|
|
58
|
+
WV,54,029,Hancock County,90540,01928192,Clay district,Z1,N
|
|
59
|
+
WV,54,029,Hancock County,91308,01928278,Grant district,Z1,N
|
|
60
|
+
WV,54,031,Hardy County,90372,01928178,Capon district,Z1,N
|
|
61
|
+
WV,54,031,Hardy County,91968,01928305,Lost River district,Z1,N
|
|
62
|
+
WV,54,031,Hardy County,92232,01928317,Moorefield district,Z1,N
|
|
63
|
+
WV,54,031,Hardy County,92382,01928334,Old Fields district,Z1,N
|
|
64
|
+
WV,54,031,Hardy County,92928,01928360,South Fork district,Z1,N
|
|
65
|
+
WV,54,033,Harrison County,90975,01928257,Eastern district,Z1,N
|
|
66
|
+
WV,54,033,Harrison County,92352,01928331,Northern district,Z1,N
|
|
67
|
+
WV,54,033,Harrison County,92368,01928326,North Urban district,Z1,N
|
|
68
|
+
WV,54,033,Harrison County,92923,01928363,Southern district,Z1,N
|
|
69
|
+
WV,54,033,Harrison County,92932,01928361,South Urban district,Z1,N
|
|
70
|
+
WV,54,033,Harrison County,92952,01928367,Southwest district,Z1,N
|
|
71
|
+
WV,54,035,Jackson County,90976,01928258,Eastern district,Z1,N
|
|
72
|
+
WV,54,035,Jackson County,92353,01928328,Northern district,Z1,N
|
|
73
|
+
WV,54,035,Jackson County,93605,01928409,Western district,Z1,N
|
|
74
|
+
WV,54,037,Jefferson County,90504,01928190,Charles Town district,Z1,N
|
|
75
|
+
WV,54,037,Jefferson County,91548,01928287,Harpers Ferry district,Z1,N
|
|
76
|
+
WV,54,037,Jefferson County,91740,01928295,Kabletown district,Z1,N
|
|
77
|
+
WV,54,037,Jefferson County,92160,01928313,Middleway district,Z1,N
|
|
78
|
+
WV,54,037,Jefferson County,92760,01928354,Shepherdstown district,Z1,N
|
|
79
|
+
WV,54,039,Kanawha County,90768,01928207,District 1,Z1,N
|
|
80
|
+
WV,54,039,Kanawha County,90804,01928218,District 2,Z1,N
|
|
81
|
+
WV,54,039,Kanawha County,90840,01928229,District 3,Z1,N
|
|
82
|
+
WV,54,039,Kanawha County,90876,01928239,District 4,Z1,N
|
|
83
|
+
WV,54,041,Lewis County,90676,01928199,Courthouse-Collins Settlement district,Z1,N
|
|
84
|
+
WV,54,041,Lewis County,91176,01928273,Freemans Creek district,Z1,N
|
|
85
|
+
WV,54,041,Lewis County,91480,01928283,Hackers Creek-Skin Creek district,Z1,N
|
|
86
|
+
WV,54,043,Lincoln County,90770,02727444,District 1,Z1,N
|
|
87
|
+
WV,54,043,Lincoln County,90806,02727447,District 2,Z1,N
|
|
88
|
+
WV,54,043,Lincoln County,90842,02727449,District 3,Z1,N
|
|
89
|
+
WV,54,045,Logan County,90453,01928182,Central district,Z1,N
|
|
90
|
+
WV,54,045,Logan County,90979,01928259,Eastern district,Z1,N
|
|
91
|
+
WV,54,045,Logan County,93608,01928410,Western district,Z1,N
|
|
92
|
+
WV,54,047,McDowell County,90168,01928167,Big Creek district,Z1,N
|
|
93
|
+
WV,54,047,McDowell County,90240,01928171,Browns Creek district,Z1,N
|
|
94
|
+
WV,54,047,McDowell County,92345,01928325,North Elkin district,Z1,N
|
|
95
|
+
WV,54,047,McDowell County,92712,01928348,Sandy River district,Z1,N
|
|
96
|
+
WV,54,049,Marion County,92154,01928312,Middletown district,Z1,N
|
|
97
|
+
WV,54,049,Marion County,92418,01928335,Palatine district,Z1,N
|
|
98
|
+
WV,54,049,Marion County,93594,01928405,West Augusta district,Z1,N
|
|
99
|
+
WV,54,051,Marshall County,90780,01928208,District 1,Z1,N
|
|
100
|
+
WV,54,051,Marshall County,90816,01928219,District 2,Z1,N
|
|
101
|
+
WV,54,051,Marshall County,90852,01928230,District 3,Z1,N
|
|
102
|
+
WV,54,053,Mason County,90048,01928162,Arbuckle district,Z1,N
|
|
103
|
+
WV,54,053,Mason County,90612,01928195,Clendenin district,Z1,N
|
|
104
|
+
WV,54,053,Mason County,90648,01928197,Cologne district,Z1,N
|
|
105
|
+
WV,54,053,Mason County,90660,01928198,Cooper district,Z1,N
|
|
106
|
+
WV,54,053,Mason County,91260,01928276,Graham district,Z1,N
|
|
107
|
+
WV,54,053,Mason County,91512,01928285,Hannan district,Z1,N
|
|
108
|
+
WV,54,053,Mason County,91860,01928302,Lewis district,Z1,N
|
|
109
|
+
WV,54,053,Mason County,92652,01928346,Robinson district,Z1,N
|
|
110
|
+
WV,54,053,Mason County,93264,01928387,Union district,Z1,N
|
|
111
|
+
WV,54,053,Mason County,93432,01928398,Waggener district,Z1,N
|
|
112
|
+
WV,54,055,Mercer County,90900,01928250,District I,Z1,N
|
|
113
|
+
WV,54,055,Mercer County,90912,01928251,District II,Z1,N
|
|
114
|
+
WV,54,055,Mercer County,90924,01928252,District III,Z1,N
|
|
115
|
+
WV,54,057,Mineral County,90784,01928209,District 1,Z1,N
|
|
116
|
+
WV,54,057,Mineral County,90820,01928220,District 2,Z1,N
|
|
117
|
+
WV,54,057,Mineral County,90856,01928231,District 3,Z1,N
|
|
118
|
+
WV,54,059,Mingo County,90141,02071872,Beech Ben Mate district,Z1,N
|
|
119
|
+
WV,54,059,Mingo County,91770,02071873,Kermit Harvey district,Z1,N
|
|
120
|
+
WV,54,059,Mingo County,91848,01928301,Lee district,Z1,N
|
|
121
|
+
WV,54,059,Mingo County,92064,01928308,Magnolia district,Z1,N
|
|
122
|
+
WV,54,059,Mingo County,93012,01928372,Stafford district,Z1,N
|
|
123
|
+
WV,54,059,Mingo County,93162,02071874,Tug Hardee district,Z1,N
|
|
124
|
+
WV,54,059,Mingo County,93696,01928420,Williamson district,Z1,N
|
|
125
|
+
WV,54,061,Monongalia County,90456,01928186,Central district,Z1,N
|
|
126
|
+
WV,54,061,Monongalia County,90983,01928263,Eastern district,Z1,N
|
|
127
|
+
WV,54,061,Monongalia County,93612,01928414,Western district,Z1,N
|
|
128
|
+
WV,54,063,Monroe County,90457,01928183,Central district,Z1,N
|
|
129
|
+
WV,54,063,Monroe County,90984,01928260,Eastern district,Z1,N
|
|
130
|
+
WV,54,063,Monroe County,93613,01928411,Western district,Z1,N
|
|
131
|
+
WV,54,065,Morgan County,90786,01928210,District 1,Z1,N
|
|
132
|
+
WV,54,065,Morgan County,90822,01928221,District 2,Z1,N
|
|
133
|
+
WV,54,065,Morgan County,90858,01928232,District 3,Z1,N
|
|
134
|
+
WV,54,067,Nicholas County,90132,01928164,Beaver district,Z1,N
|
|
135
|
+
WV,54,067,Nicholas County,91344,01928279,Grant district,Z1,N
|
|
136
|
+
WV,54,067,Nicholas County,91500,01928284,Hamilton district,Z1,N
|
|
137
|
+
WV,54,067,Nicholas County,91716,01928294,Jefferson district,Z1,N
|
|
138
|
+
WV,54,067,Nicholas County,91752,01928296,Kentucky district,Z1,N
|
|
139
|
+
WV,54,067,Nicholas County,93072,01928376,Summersville district,Z1,N
|
|
140
|
+
WV,54,067,Nicholas County,93660,01928418,Wilderness district,Z1,N
|
|
141
|
+
WV,54,069,Ohio County,90788,01928211,District 1,Z1,N
|
|
142
|
+
WV,54,069,Ohio County,90824,01928222,District 2,Z1,N
|
|
143
|
+
WV,54,069,Ohio County,90862,01928233,District 3,Z1,N
|
|
144
|
+
WV,54,071,Pendleton County,90462,01928184,Central district,Z1,N
|
|
145
|
+
WV,54,071,Pendleton County,90987,01928261,Eastern district,Z1,N
|
|
146
|
+
WV,54,071,Pendleton County,93615,01928412,Western district,Z1,N
|
|
147
|
+
WV,54,073,Pleasants County,90892,01928243,District A,Z1,N
|
|
148
|
+
WV,54,073,Pleasants County,90894,01928245,District B,Z1,N
|
|
149
|
+
WV,54,073,Pleasants County,90896,01928247,District C,Z1,N
|
|
150
|
+
WV,54,073,Pleasants County,90898,01928249,District D,Z1,N
|
|
151
|
+
WV,54,075,Pocahontas County,90996,01928266,Edray district,Z1,N
|
|
152
|
+
WV,54,075,Pocahontas County,91416,01928281,Greenbank district,Z1,N
|
|
153
|
+
WV,54,075,Pocahontas County,91656,01928291,Huntersville district,Z1,N
|
|
154
|
+
WV,54,075,Pocahontas County,91944,01928304,Little Levels district,Z1,N
|
|
155
|
+
WV,54,077,Preston County,91096,01928268,Fifth district,Z1,N
|
|
156
|
+
WV,54,077,Preston County,91100,01928269,First district,Z1,N
|
|
157
|
+
WV,54,077,Preston County,91134,01928272,Fourth district,Z1,N
|
|
158
|
+
WV,54,077,Preston County,92742,01928350,Second district,Z1,N
|
|
159
|
+
WV,54,077,Preston County,93102,01928379,Third district,Z1,N
|
|
160
|
+
WV,54,079,Putnam County,90790,02807599,District 1,Z1,N
|
|
161
|
+
WV,54,079,Putnam County,90826,02807600,District 2,Z1,N
|
|
162
|
+
WV,54,079,Putnam County,90863,02807601,District 3,Z1,N
|
|
163
|
+
WV,54,081,Raleigh County,90792,01928212,District 1,Z1,N
|
|
164
|
+
WV,54,081,Raleigh County,90828,01928223,District 2,Z1,N
|
|
165
|
+
WV,54,081,Raleigh County,90864,01928234,District 3,Z1,N
|
|
166
|
+
WV,54,083,Randolph County,90156,01928166,Beverly district,Z1,N
|
|
167
|
+
WV,54,083,Randolph County,90936,01928253,Dry Fork district,Z1,N
|
|
168
|
+
WV,54,083,Randolph County,91668,01928292,Huttonsville district,Z1,N
|
|
169
|
+
WV,54,083,Randolph County,91824,01928300,Leadsville district,Z1,N
|
|
170
|
+
WV,54,083,Randolph County,92148,01928311,Middle Fork district,Z1,N
|
|
171
|
+
WV,54,083,Randolph County,92220,01928316,Mingo district,Z1,N
|
|
172
|
+
WV,54,083,Randolph County,92292,01928320,New Interest district,Z1,N
|
|
173
|
+
WV,54,083,Randolph County,92640,01928345,Roaring Creek district,Z1,N
|
|
174
|
+
WV,54,083,Randolph County,93420,01928395,Valley Bend district,Z1,N
|
|
175
|
+
WV,54,085,Ritchie County,90552,01928193,Clay district,Z1,N
|
|
176
|
+
WV,54,085,Ritchie County,91380,01928280,Grant district,Z1,N
|
|
177
|
+
WV,54,085,Ritchie County,92244,01928318,Murphy district,Z1,N
|
|
178
|
+
WV,54,085,Ritchie County,93336,01928390,Union district,Z1,N
|
|
179
|
+
WV,54,087,Roane County,90906,01953485,District I,Z1,N
|
|
180
|
+
WV,54,087,Roane County,90918,01953486,District II,Z1,N
|
|
181
|
+
WV,54,087,Roane County,90930,01953487,District III,Z1,N
|
|
182
|
+
WV,54,089,Summers County,90216,01928170,Bluestone River district,Z1,N
|
|
183
|
+
WV,54,089,Summers County,91440,01928282,Greenbrier River district,Z1,N
|
|
184
|
+
WV,54,089,Summers County,92316,01928321,New River district,Z1,N
|
|
185
|
+
WV,54,091,Taylor County,90993,01928265,Eastern district,Z1,N
|
|
186
|
+
WV,54,091,Taylor County,93175,01928383,Tygart district,Z1,N
|
|
187
|
+
WV,54,091,Taylor County,93621,01928416,Western district,Z1,N
|
|
188
|
+
WV,54,093,Tucker County,90192,01928168,Black Fork district,Z1,N
|
|
189
|
+
WV,54,093,Tucker County,90624,01928196,Clover district,Z1,N
|
|
190
|
+
WV,54,093,Tucker County,90744,01928202,Davis district,Z1,N
|
|
191
|
+
WV,54,093,Tucker County,90948,01928254,Dry Fork district,Z1,N
|
|
192
|
+
WV,54,093,Tucker County,91056,01928267,Fairfax district,Z1,N
|
|
193
|
+
WV,54,093,Tucker County,91896,01928303,Licking district,Z1,N
|
|
194
|
+
WV,54,093,Tucker County,92688,01928371,St. George district,Z1,N
|
|
195
|
+
WV,54,095,Tyler County,90469,01928187,Central district,Z1,N
|
|
196
|
+
WV,54,095,Tyler County,92334,01928324,North district,Z1,N
|
|
197
|
+
WV,54,095,Tyler County,92898,01928359,South district,Z1,N
|
|
198
|
+
WV,54,095,Tyler County,93592,01928407,West district,Z1,N
|
|
199
|
+
WV,54,097,Upshur County,91102,01928270,First district,Z1,N
|
|
200
|
+
WV,54,097,Upshur County,92745,01928351,Second district,Z1,N
|
|
201
|
+
WV,54,097,Upshur County,93105,01928380,Third district,Z1,N
|
|
202
|
+
WV,54,099,Wayne County,90324,01928176,Butler district,Z1,N
|
|
203
|
+
WV,54,099,Wayne County,90492,01928189,Ceredo district,Z1,N
|
|
204
|
+
WV,54,099,Wayne County,93036,01928374,Stonewall district,Z1,N
|
|
205
|
+
WV,54,099,Wayne County,93372,01928392,Union district,Z1,N
|
|
206
|
+
WV,54,099,Wayne County,93624,01928417,Westmoreland district,Z1,N
|
|
207
|
+
WV,54,101,Webster County,90471,01928185,Central district,Z1,N
|
|
208
|
+
WV,54,101,Webster County,92360,01928329,Northern district,Z1,N
|
|
209
|
+
WV,54,101,Webster County,92925,01928365,Southern district,Z1,N
|
|
210
|
+
WV,54,103,Wetzel County,90794,01928213,District 1,Z1,N
|
|
211
|
+
WV,54,103,Wetzel County,90830,01928224,District 2,Z1,N
|
|
212
|
+
WV,54,103,Wetzel County,90867,01928235,District 3,Z1,N
|
|
213
|
+
WV,54,105,Wirt County,90473,01928188,Central district,Z1,N
|
|
214
|
+
WV,54,105,Wirt County,92344,01928327,Northeast district,Z1,N
|
|
215
|
+
WV,54,105,Wirt County,92958,01928368,Southwest district,Z1,N
|
|
216
|
+
WV,54,107,Wood County,90588,01928194,Clay district,Z1,N
|
|
217
|
+
WV,54,107,Wood County,91560,01928288,Harris district,Z1,N
|
|
218
|
+
WV,54,107,Wood County,91980,01928306,Lubeck district,Z1,N
|
|
219
|
+
WV,54,107,Wood County,92424,01928336,Parkersburg district,Z1,N
|
|
220
|
+
WV,54,107,Wood County,92856,01928357,Slate district,Z1,N
|
|
221
|
+
WV,54,107,Wood County,93024,01928373,Steele district,Z1,N
|
|
222
|
+
WV,54,107,Wood County,93180,01928384,Tygart district,Z1,N
|
|
223
|
+
WV,54,107,Wood County,93384,01928393,Union district,Z1,N
|
|
224
|
+
WV,54,107,Wood County,93444,01928399,Walker district,Z1,N
|
|
225
|
+
WV,54,107,Wood County,93672,01928419,Williams district,Z1,N
|
|
226
|
+
WV,54,109,Wyoming County,90795,01928214,District 1,Z1,N
|
|
227
|
+
WV,54,109,Wyoming County,90831,01928225,District 2,Z1,N
|
|
228
|
+
WV,54,109,Wyoming County,90868,01928236,District 3,Z1,N
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
WY,56,001,Albany County,91100,01939703,East Albany CCD,Z5,S
|
|
2
|
+
WY,56,001,Albany County,92090,01939721,Laramie CCD,Z5,S
|
|
3
|
+
WY,56,001,Albany County,92695,01939732,Rock River CCD,Z5,S
|
|
4
|
+
WY,56,001,Albany County,93135,01939740,South Albany CCD,Z5,S
|
|
5
|
+
WY,56,003,Big Horn County,90688,01939686,Central Big Horn CCD,Z5,S
|
|
6
|
+
WY,56,003,Big Horn County,92393,01939687,North Big Horn CCD,Z5,S
|
|
7
|
+
WY,56,003,Big Horn County,93142,01939688,South Big Horn CCD,Z5,S
|
|
8
|
+
WY,56,005,Campbell County,91210,01939705,Gillette North CCD,Z5,S
|
|
9
|
+
WY,56,005,Campbell County,91265,01939706,Gillette South CCD,Z5,S
|
|
10
|
+
WY,56,007,Carbon County,91650,01939713,Hanna CCD,Z5,S
|
|
11
|
+
WY,56,007,Carbon County,92640,01939731,Rawlins CCD,Z5,S
|
|
12
|
+
WY,56,007,Carbon County,92860,01939735,Saratoga CCD,Z5,S
|
|
13
|
+
WY,56,009,Converse County,90990,01939701,Douglas CCD,Z5,S
|
|
14
|
+
WY,56,009,Converse County,91375,01939708,Glenrock CCD,Z5,S
|
|
15
|
+
WY,56,011,Crook County,91760,01939715,Hulett CCD,Z5,S
|
|
16
|
+
WY,56,011,Crook County,92200,01939723,Moorcroft CCD,Z5,S
|
|
17
|
+
WY,56,011,Crook County,93190,01939741,Sundance CCD,Z5,S
|
|
18
|
+
WY,56,013,Fremont County,91045,01939702,Dubois CCD,Z5,S
|
|
19
|
+
WY,56,013,Fremont County,91842,01939742,Jeffrey City CCD,Z5,S
|
|
20
|
+
WY,56,013,Fremont County,92035,01939720,Lander CCD,Z5,S
|
|
21
|
+
WY,56,013,Fremont County,93080,01939739,Shoshoni CCD,Z5,S
|
|
22
|
+
WY,56,013,Fremont County,93742,01939750,Wind River Reservation CCD,Z5,S
|
|
23
|
+
WY,56,015,Goshen County,91430,01939709,Goshen Hole CCD,Z5,S
|
|
24
|
+
WY,56,015,Goshen County,92585,01939730,Rawhide Creek CCD,Z5,S
|
|
25
|
+
WY,56,015,Goshen County,93465,01939746,Torrington CCD,Z5,S
|
|
26
|
+
WY,56,017,Hot Springs County,93355,01939744,Thermopolis East CCD,Z5,S
|
|
27
|
+
WY,56,017,Hot Springs County,93410,01939745,Thermopolis West CCD,Z5,S
|
|
28
|
+
WY,56,017,Hot Springs County,93744,01939751,Wind River Reservation CCD,Z5,S
|
|
29
|
+
WY,56,019,Johnson County,90495,01939692,Buffalo CCD,Z5,S
|
|
30
|
+
WY,56,019,Johnson County,91870,01939717,Kaycee CCD,Z5,S
|
|
31
|
+
WY,56,021,Laramie County,90715,01939696,Cheyenne CCD,Z5,S
|
|
32
|
+
WY,56,021,Laramie County,90770,01939697,Cheyenne East CCD,Z5,S
|
|
33
|
+
WY,56,021,Laramie County,90825,01939698,Cheyenne West CCD,Z5,S
|
|
34
|
+
WY,56,021,Laramie County,92420,01939727,Pine Bluffs CCD,Z5,S
|
|
35
|
+
WY,56,023,Lincoln County,90055,01939684,Afton CCD,Z5,S
|
|
36
|
+
WY,56,023,Lincoln County,91925,01939718,Kemmerer East CCD,Z5,S
|
|
37
|
+
WY,56,023,Lincoln County,91980,01939719,Kemmerer West CCD,Z5,S
|
|
38
|
+
WY,56,025,Natrona County,90550,01939693,Casper CCD,Z5,S
|
|
39
|
+
WY,56,025,Natrona County,90605,01939694,Casper North CCD,Z5,S
|
|
40
|
+
WY,56,025,Natrona County,90660,01939695,Casper South CCD,Z5,S
|
|
41
|
+
WY,56,025,Natrona County,91705,01939714,Hells Half Acre CCD,Z5,S
|
|
42
|
+
WY,56,027,Niobrara County,91128,01939725,East Niobrara CCD,Z5,S
|
|
43
|
+
WY,56,027,Niobrara County,93603,01939726,West Niobrara CCD,Z5,S
|
|
44
|
+
WY,56,029,Park County,90935,01939700,Cody CCD,Z5,S
|
|
45
|
+
WY,56,029,Park County,92145,01939722,Meeteetse CCD,Z5,S
|
|
46
|
+
WY,56,029,Park County,92530,01939729,Powell CCD,Z5,S
|
|
47
|
+
WY,56,029,Park County,93850,01939753,Yellowstone National Park CCD,Z5,S
|
|
48
|
+
WY,56,031,Platte County,90880,01939699,Chugwater CCD,Z5,S
|
|
49
|
+
WY,56,031,Platte County,91320,01939707,Glendo CCD,Z5,S
|
|
50
|
+
WY,56,031,Platte County,91595,01939712,Guernsey CCD,Z5,S
|
|
51
|
+
WY,56,031,Platte County,93630,01939749,Wheatland CCD,Z5,S
|
|
52
|
+
WY,56,033,Sheridan County,92915,01939736,Sheridan CCD,Z5,S
|
|
53
|
+
WY,56,033,Sheridan County,92970,01939737,Sheridan South CCD,Z5,S
|
|
54
|
+
WY,56,033,Sheridan County,93025,01939738,Sheridan West CCD,Z5,S
|
|
55
|
+
WY,56,035,Sublette County,90330,01939689,Big Piney CCD,Z5,S
|
|
56
|
+
WY,56,035,Sublette County,90385,01939690,Boulder CCD,Z5,S
|
|
57
|
+
WY,56,035,Sublette County,92475,01939728,Pinedale CCD,Z5,S
|
|
58
|
+
WY,56,037,Sweetwater County,91485,01939710,Green River North CCD,Z5,S
|
|
59
|
+
WY,56,037,Sweetwater County,91540,01939711,Green River South CCD,Z5,S
|
|
60
|
+
WY,56,037,Sweetwater County,92750,01939733,Rock Springs North CCD,Z5,S
|
|
61
|
+
WY,56,037,Sweetwater County,92805,01939734,Rock Springs South CCD,Z5,S
|
|
62
|
+
WY,56,037,Sweetwater County,93575,01939748,Wamsutter CCD,Z5,S
|
|
63
|
+
WY,56,039,Teton County,90110,01939685,Alta CCD,Z5,S
|
|
64
|
+
WY,56,039,Teton County,91815,01939716,Jackson Hole CCD,Z5,S
|
|
65
|
+
WY,56,039,Teton County,93905,01939754,Yellowstone National Park CCD,Z5,S
|
|
66
|
+
WY,56,041,Uinta County,90440,01939691,Bridger Valley CCD,Z5,S
|
|
67
|
+
WY,56,041,Uinta County,91155,01939704,Evanston CCD,Z5,S
|
|
68
|
+
WY,56,043,Washakie County,93300,01939743,Ten Sleep CCD,Z5,S
|
|
69
|
+
WY,56,043,Washakie County,93795,01939752,Worland CCD,Z5,S
|
|
70
|
+
WY,56,045,Weston County,92255,01939724,Newcastle CCD,Z5,S
|
|
71
|
+
WY,56,045,Weston County,93520,01939747,Upton CCD,Z5,S
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# County related section of FipsLookup module
|
|
4
|
+
module FipsLookup
|
|
5
|
+
class << self
|
|
6
|
+
def county(state_param:, county_param:, return_nil: false)
|
|
7
|
+
state_code = find_state_code(state_param: state_param, return_nil: return_nil)
|
|
8
|
+
return {} if state_code.nil?
|
|
9
|
+
|
|
10
|
+
lookup = [state_code, county_param.upcase]
|
|
11
|
+
@county_fips ||= {}
|
|
12
|
+
@county_fips[lookup] ||= county_lookup(state_code, county_param, return_nil)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def fips_county(fips:, return_nil: false)
|
|
16
|
+
unless fips.is_a?(String) && fips.length == 5
|
|
17
|
+
return_nil ? (return nil) : (raise StandardError, "FIPS input must be 5 digit string")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
state_code = find_state_code(state_param: fips[0..1], return_nil: return_nil)
|
|
21
|
+
return nil if state_code.nil?
|
|
22
|
+
|
|
23
|
+
CSV.foreach(county_file(state_code: state_code)) do |county_row|
|
|
24
|
+
# state_code (AL), state fips (01), county fips (001), name (Augtauga County), county gnis(00161526), class code (H1), status (A)
|
|
25
|
+
return [county_row[3], state_code] if county_row[2] == fips[2..4]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
raise StandardError, "Could not find county with fips: #{fips[2..4]}, in: #{state_code}" unless return_nil
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def county_file(state_code:)
|
|
32
|
+
file_path = "#{File.expand_path("..", __dir__)}/data/county/#{state_code}.csv"
|
|
33
|
+
file_path if File.exist?(file_path)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def county_lookup(state_code, county_param, return_nil)
|
|
39
|
+
upcase_param = county_param.upcase
|
|
40
|
+
CSV.foreach(county_file(state_code: state_code)) do |row|
|
|
41
|
+
return formatted_county(row) if match_county?(row, upcase_param)
|
|
42
|
+
|
|
43
|
+
# keep? Memoize as file is being read but match isn't found ~ loses lookup flexiblity in county param + increases performacne?
|
|
44
|
+
@county_fips[[row[0], row[3].upcase]] = formatted_county(row) unless @county_fips.key?([row[0], row[3].upcase])
|
|
45
|
+
end
|
|
46
|
+
return_nil ? (return {}) : (raise StandardError, "No county found matching: #{county_param}" unless return_nil)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def match_county?(row, param)
|
|
50
|
+
# row => state (AL), state fips (01), county fips (001), name (Augtauga County), county gnis (00161526), class code (H1), status (A)
|
|
51
|
+
row[3].upcase == param || row[4] == param || row[2] == param || "#{row[1]}#{row[2]}" == param
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def formatted_county(row)
|
|
55
|
+
{
|
|
56
|
+
state_code: row[0],
|
|
57
|
+
fips: (row[1] + row[2]),
|
|
58
|
+
gnis: row[4],
|
|
59
|
+
name: row[3],
|
|
60
|
+
class_code: row[5],
|
|
61
|
+
status: row[6]
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# State related section of FipsLookup module
|
|
4
|
+
module FipsLookup
|
|
5
|
+
class << self
|
|
6
|
+
def state(state_param:, return_nil: false)
|
|
7
|
+
@state_fips ||= {}
|
|
8
|
+
@state_fips[state_param] ||= state_lookup(state_param, return_nil)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def find_state_code(state_param:, return_nil: false)
|
|
12
|
+
return state_param.upcase if STATE_CODES.key?(state_param.upcase)
|
|
13
|
+
return STATE_CODES.key(state_param) if STATE_CODES.value?(state_param)
|
|
14
|
+
|
|
15
|
+
state(state_param: state_param, return_nil: return_nil)[:code]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def state_file
|
|
19
|
+
"#{File.expand_path("..", __dir__)}/data/state.csv"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def state_lookup(state_param, return_nil = false)
|
|
25
|
+
upstate_param = state_param.upcase
|
|
26
|
+
CSV.foreach(state_file) do |state_row|
|
|
27
|
+
return formatted_state(state_row) if state_match_row?(state_row, upstate_param)
|
|
28
|
+
end
|
|
29
|
+
return_nil ? (return {}) : (raise StandardError, "No state found matching: #{state_param}")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def state_match_row?(row, param)
|
|
33
|
+
# row => state fips (01), state code (AL), state name (Alabama), ansi (01779775)
|
|
34
|
+
row[0] == param || row[1] == param || row[2].upcase == param || row[3] == param
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def formatted_state(row)
|
|
38
|
+
{
|
|
39
|
+
fips: row[0],
|
|
40
|
+
code: row[1],
|
|
41
|
+
name: row[2],
|
|
42
|
+
ansi: row[3]
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Subdivision related section of FIPS module
|
|
4
|
+
module FipsLookup
|
|
5
|
+
class << self
|
|
6
|
+
def subdivision(state_param:, subdivision_param:, return_nil: false)
|
|
7
|
+
state_code = find_state_code(state_param: state_param, return_nil: return_nil)
|
|
8
|
+
return {} if state_code.nil?
|
|
9
|
+
|
|
10
|
+
lookup = [state_code, subdivision_param.upcase]
|
|
11
|
+
@subdivision_fips ||= {}
|
|
12
|
+
@subdivision_fips[lookup] ||= subdivision_lookup(state_code, subdivision_param, return_nil)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def subdivision_file(state_code:)
|
|
16
|
+
file_path = "#{File.expand_path("..", __dir__)}/data/subdivision/#{state_code}.csv"
|
|
17
|
+
file_path if File.exist?(file_path)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def subdivision_lookup(state_code, subdivision_param, return_nil)
|
|
23
|
+
upcase_param = subdivision_param.upcase
|
|
24
|
+
CSV.foreach(subdivision_file(state_code: state_code)) do |subdivision_row|
|
|
25
|
+
return formatted_subdivision(subdivision_row) if match_subdivision?(subdivision_row, upcase_param)
|
|
26
|
+
end
|
|
27
|
+
return_nil ? (return {}) : (raise StandardError, "No subdivision found matching: #{subdivision_param}" unless return_nil)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def match_subdivision?(row, param)
|
|
31
|
+
# row => state_code (AL), state fips (01), county fips (001), county name (Augtauga County)
|
|
32
|
+
# row => subdivision name(Autaugaville CCD), class code (Z5), status (S)
|
|
33
|
+
row[6].upcase == param || row[4] == param || row[5] == param
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def formatted_subdivision(row)
|
|
37
|
+
{
|
|
38
|
+
state_code: row[0],
|
|
39
|
+
fips: row[1] + row[2] + row[4],
|
|
40
|
+
county_name: row[3],
|
|
41
|
+
gnis: row[5],
|
|
42
|
+
name: row[6],
|
|
43
|
+
class_code: row[7],
|
|
44
|
+
status: row[8]
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/fips_lookup/version.rb
CHANGED
data/lib/fips_lookup.rb
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "fips_lookup/version"
|
|
4
3
|
require "csv"
|
|
4
|
+
require_relative "fips_lookup/version"
|
|
5
|
+
require_relative "fips_lookup/subdivision"
|
|
6
|
+
require_relative "fips_lookup/county"
|
|
7
|
+
require_relative "fips_lookup/state"
|
|
5
8
|
|
|
6
|
-
#
|
|
9
|
+
# parent section of module defining constants, requiring relative worker methods
|
|
7
10
|
module FipsLookup
|
|
8
11
|
STATE_CODES = { "AL" => "01", "AK" => "02", "AZ" => "04", "AR" => "05", "CA" => "06", "CO" => "08",
|
|
9
12
|
"CT" => "09", "DE" => "10", "DC" => "11", "FL" => "12", "GA" => "13", "HI" => "15",
|
|
@@ -14,78 +17,9 @@ module FipsLookup
|
|
|
14
17
|
"OK" => "40", "OR" => "41", "PA" => "42", "RI" => "44", "SC" => "45", "SD" => "46",
|
|
15
18
|
"TN" => "47", "TX" => "48", "UT" => "49", "VT" => "50", "VA" => "51", "WA" => "53",
|
|
16
19
|
"WV" => "54", "WI" => "55", "WY" => "56", "AS" => "60", "GU" => "66", "MP" => "69",
|
|
17
|
-
"PR" => "72", "UM" => "74", "VI" => "78"
|
|
18
|
-
}.freeze
|
|
20
|
+
"PR" => "72", "UM" => "74", "VI" => "78" }.freeze
|
|
19
21
|
|
|
20
22
|
class << self
|
|
21
|
-
attr_accessor :county_fips, :state_fips
|
|
22
|
-
|
|
23
|
-
def county(state_param:, county_name:, return_nil: false)
|
|
24
|
-
state_code = find_state_code(state_param: state_param, return_nil: return_nil)
|
|
25
|
-
return {} if state_code.nil?
|
|
26
|
-
|
|
27
|
-
lookup = [state_code, county_name.upcase]
|
|
28
|
-
@county_fips ||= {}
|
|
29
|
-
@county_fips[lookup] ||= county_lookup(state_code, county_name, return_nil)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def state(state_param:, return_nil: false)
|
|
33
|
-
@state_fips ||= {}
|
|
34
|
-
@state_fips[state_param] ||= state_lookup(state_param, return_nil)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def fips_county(fips:, return_nil: false)
|
|
38
|
-
unless fips.is_a?(String) && fips.length == 5
|
|
39
|
-
return_nil ? (return nil) : (raise StandardError, "FIPS input must be 5 digit string")
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
state_code = find_state_code(state_param: fips[0..1], return_nil: return_nil)
|
|
43
|
-
return nil if state_code.nil?
|
|
44
|
-
|
|
45
|
-
CSV.foreach(county_file(state_code: state_code)) do |county_row|
|
|
46
|
-
return [county_row[3], state_code] if county_row[2] == fips[2..4]
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
raise StandardError, "Could not find county with fips: #{fips[2..4]}, in: #{state_code}" unless return_nil
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def find_state_code(state_param:, return_nil: false)
|
|
53
|
-
return state_param.upcase if STATE_CODES.key?(state_param.upcase)
|
|
54
|
-
return STATE_CODES.key(state_param) if STATE_CODES.value?(state_param)
|
|
55
|
-
|
|
56
|
-
state(state_param: state_param, return_nil: return_nil)[:code]
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def county_file(state_code:)
|
|
60
|
-
file_path = "#{File.expand_path(__dir__)}/data/county/#{state_code}.csv"
|
|
61
|
-
file_path if File.exist?(file_path)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def state_file
|
|
65
|
-
"#{File.expand_path(__dir__)}/data/state.csv"
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
private
|
|
69
|
-
|
|
70
|
-
def county_lookup(state_code, county_name_param, return_nil)
|
|
71
|
-
CSV.foreach(county_file(state_code: state_code)) do |county_row|
|
|
72
|
-
# county_row => state_code (AL), state fips (01), county fips (001), name (Augtauga County), class code (H1)
|
|
73
|
-
if county_row[3].upcase == county_name_param.upcase
|
|
74
|
-
return {state_code: county_row[0], fips: (county_row[1] + county_row[2]), name: county_row[3], class_code: county_row[4] }
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
return_nil ? (return {}) : (raise StandardError, "No county found matching: #{county_name_param}" unless return_nil)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def state_lookup(state_param, return_nil = false)
|
|
81
|
-
CSV.foreach(state_file) do |state_row|
|
|
82
|
-
# state_row => state fips (01), state code (AL), state name (Alabama), ansi (01779775)
|
|
83
|
-
if state_row[0] == state_param || state_row[1] == state_param.upcase ||
|
|
84
|
-
state_row[2].upcase == state_param.upcase || state_row[3] == state_param
|
|
85
|
-
return { fips: state_row[0], code: state_row[1], name: state_row[2], ansi: state_row[3] }
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
return_nil ? (return {}) : (raise StandardError, "No state found matching: #{state_param}")
|
|
89
|
-
end
|
|
23
|
+
attr_accessor :county_fips, :state_fips, :subdivision_fips
|
|
90
24
|
end
|
|
91
25
|
end
|