jisx0402 1.2.0 → 1.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/lib/jisx0402.rb +17 -0
- data/lib/jisx0402/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3eeaae7e2665770a20e0402766cdc7e0635fd49
|
4
|
+
data.tar.gz: f67f713ed9d06b10856c7a026580131fd2a1fbdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45cbe2012cc63feff2b0ace61aeb2880bc3be47fdcc796f1f2312c10978eda9162c172fe171f63461515dd114da4b092ab5e21bbeb9293ee8c14b4ea2998548f
|
7
|
+
data.tar.gz: e3c26331327591aaab06d3703e859e18813336cc05ae1bd984a90d4e73e8be2a0ac7a30343bbb128037de8537cbf7c461fbdaecd22ed0408c7306e612389d65c
|
data/lib/jisx0402.rb
CHANGED
@@ -11,6 +11,17 @@ module Jisx0402
|
|
11
11
|
data
|
12
12
|
end
|
13
13
|
|
14
|
+
def find_by_code(c)
|
15
|
+
code = c.to_s
|
16
|
+
if code.size == 2 && (1..47).cover?(code.to_i)
|
17
|
+
code_without_checkdigit = "#{code}000" # 都道府県
|
18
|
+
else
|
19
|
+
code_without_checkdigit = code[0..4] # Eliminate checkdigit
|
20
|
+
end
|
21
|
+
|
22
|
+
jisx0402_without_checkdigit_table[code_without_checkdigit]
|
23
|
+
end
|
24
|
+
|
14
25
|
def forward_match_by_full(chunk)
|
15
26
|
forward_match_by(:full, chunk)
|
16
27
|
end
|
@@ -69,6 +80,12 @@ module Jisx0402
|
|
69
80
|
end
|
70
81
|
end
|
71
82
|
|
83
|
+
def jisx0402_without_checkdigit_table
|
84
|
+
@jisx0402_table ||= begin
|
85
|
+
data.map{ |d| [d.code_without_checkdigit, d] }.to_h
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
72
89
|
def jisx0402_to_zipcode_table
|
73
90
|
@@jisx0402_to_zipcode_table ||= open_data('jisx0402_to_zipcode')
|
74
91
|
end
|
data/lib/jisx0402/version.rb
CHANGED