Method: Faker::Code.sin
- Defined in:
- lib/faker/default/code.rb
.sin ⇒ String
Produces a random SIN (Social Insurance Number for Canada) code.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/faker/default/code.rb', line 150 def sin # 1 - province or temporary resident # 2-8 - random numbers # 9 - checksum # 1st digit. 8,0 are not used registry = Faker::Base.sample([1, 2, 3, 4, 5, 6, 7, 9]).to_s # generate 2nd to 8th partial = Array.new(7) { Faker::Config.random.rand(0..9) }.join # Generate 9th digit check_digit = generate_sin_check_digit("#{registry}#{partial}0").to_s registry + partial + check_digit end |