Sha256: 79967d8e2be2f553157802068d9f85762400a7fd66c60af512752fbb416d7e40
Contents?: true
Size: 686 Bytes
Versions: 2
Compression:
Stored size: 686 Bytes
Contents
# encoding: utf-8 module FFaker module IdentificationKr extend ModuleUtils extend self # Resident Registration Number # http://ko.wikipedia.org/wiki/%EC%A3%BC%EB%AF%BC%EB%93%B1%EB%A1%9D%EB%B2%88%ED%98%B8 def rrn birth = [*Date.new(1970, 1, 1)..Date.new(1999, 12, 31)].sample.strftime("%y%d%m") sex = [1, 2].sample loc = FFaker.numerify("#{[*"00".."95"].sample}###") a, b, c, d, e, f, g, h, i, j, k, l = "#{birth}#{sex}#{loc}".split(//).map(&:to_i) checksum = (11 - (2 * a + 3 * b + 4 * c + 5 * d + 6 * e + 7 * f + 8 * g + 9 * h + 2 * i + 3 * j + 4 * k + 5 * l) % 11) % 10 "#{birth}-#{sex}#{loc}#{checksum}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ffaker-2.2.0 | lib/ffaker/identification_kr.rb |
ffaker-2.1.0 | lib/ffaker/identification_kr.rb |