jisx0402 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jisx0402.rb +36 -1
- data/lib/jisx0402/district_array.rb +4 -0
- data/lib/jisx0402/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd262b9bf6cddc56cf73871c49364a6ec13987d4
|
4
|
+
data.tar.gz: 223a359bfdd1be71794138d842f47ce6dc37e065
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9a70e935fb241eb69e21f2d1bbfe1d17cba26e40e427e5d3b14b11177e44a713eeea1ba5dddc9e97672a1fcd5886b3d8562325a610ab5af2a87532e4d41f449
|
7
|
+
data.tar.gz: c999eedc62ef3442956ea5410fad7c0ef289f6fc4e68364b458aa6898edb2c7186dc8378a9bdae6f29f27613021099a2006e33ce2582bb65bad9fa0d57eeff26
|
data/lib/jisx0402.rb
CHANGED
@@ -124,7 +124,30 @@ module Jisx0402
|
|
124
124
|
end
|
125
125
|
|
126
126
|
def code_without_checkdigit
|
127
|
-
|
127
|
+
code[0..-2]
|
128
|
+
end
|
129
|
+
|
130
|
+
def district_code
|
131
|
+
@district_code ||= code[2..4]
|
132
|
+
end
|
133
|
+
|
134
|
+
def prefecture?
|
135
|
+
district_code == '000'.freeze
|
136
|
+
end
|
137
|
+
|
138
|
+
GOVERNMENT_ORDINANCE_DESIGNATED_CITY_CODE_LIST = %(100 130 140 150).freeze
|
139
|
+
def government_ordinance_designated_city?
|
140
|
+
@government_ordinance_designated_city ||= begin
|
141
|
+
GOVERNMENT_ORDINANCE_DESIGNATED_CITY_CODE_LIST.include?(district_code)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def ward?
|
146
|
+
@ward ||= (100..199).cover?(district_code.to_i)
|
147
|
+
end
|
148
|
+
|
149
|
+
def prefecture_code
|
150
|
+
code[0..1]
|
128
151
|
end
|
129
152
|
|
130
153
|
def prefecture(hiragana: false)
|
@@ -146,7 +169,19 @@ module Jisx0402
|
|
146
169
|
def zipcodes
|
147
170
|
Jisx0402.jisx0402_to_zipcode_table[code_without_checkdigit] || []
|
148
171
|
end
|
172
|
+
|
173
|
+
def cover?(c)
|
174
|
+
area_code = c.to_s
|
175
|
+
if prefecture?
|
176
|
+
area_code.start_with?(prefecture_code)
|
177
|
+
elsif government_ordinance_designated_city?
|
178
|
+
Jisx0402.forward_match_by_full(full).codes.include?(area_code)
|
179
|
+
else
|
180
|
+
code == area_code
|
181
|
+
end
|
182
|
+
end
|
149
183
|
end
|
150
184
|
end
|
151
185
|
|
186
|
+
# Warmpup zipcodes converting table and district codes tree cache.
|
152
187
|
Jisx0402.warmup
|
data/lib/jisx0402/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jisx0402
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cnosuke
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|