Module: FFaker::SSN

Extended by:
ModuleUtils, SSN
Included in:
SSN
Defined in:
lib/ffaker/ssn.rb

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, luhn_check, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Instance Method Details

#ssnObject

The Social Security number is a nine-digit number in the format “AAA-GG-SSSS”. More info here:

en.wikipedia.org/wiki/Social_Security_number



13
14
15
16
17
18
19
20
21
22
# File 'lib/ffaker/ssn.rb', line 13

def ssn
  first_group  = fetch_sample([*1..665, *667..899])
  second_group = rand(1..99)
  third_group  = rand(1..9999)

  format(
    '%<first_group>.3d-%<second_group>.2d-%<third_group>.4d',
    first_group: first_group, second_group: second_group, third_group: third_group
  )
end