jisx0402 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd262b9bf6cddc56cf73871c49364a6ec13987d4
4
- data.tar.gz: 223a359bfdd1be71794138d842f47ce6dc37e065
3
+ metadata.gz: f3eeaae7e2665770a20e0402766cdc7e0635fd49
4
+ data.tar.gz: f67f713ed9d06b10856c7a026580131fd2a1fbdc
5
5
  SHA512:
6
- metadata.gz: f9a70e935fb241eb69e21f2d1bbfe1d17cba26e40e427e5d3b14b11177e44a713eeea1ba5dddc9e97672a1fcd5886b3d8562325a610ab5af2a87532e4d41f449
7
- data.tar.gz: c999eedc62ef3442956ea5410fad7c0ef289f6fc4e68364b458aa6898edb2c7186dc8378a9bdae6f29f27613021099a2006e33ce2582bb65bad9fa0d57eeff26
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
@@ -1,3 +1,3 @@
1
1
  module Jisx0402
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jisx0402
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - cnosuke