class Faker::Code

def sin

Returns:
  • (String) -
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