Module: FFaker::CompanyFR

Extended by:
CompanyFR, ModuleUtils
Included in:
CompanyFR
Defined in:
lib/ffaker/company_fr.rb

Constant Summary collapse

SUFFIXES =
['SA', 'et fils', 'SARL', 'Groupe'].freeze

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

#nameObject



10
11
12
13
14
15
16
# File 'lib/ffaker/company_fr.rb', line 10

def name
  case rand(0..2)
  when 0 then "#{NameFR.last_name} #{suffix}"
  when 1 then "#{NameFR.last_name}-#{NameFR.last_name}"
  when 2 then "#{NameFR.last_name}, #{NameFR.last_name} and #{NameFR.last_name}"
  end
end

#sirenObject



23
24
25
26
# File 'lib/ffaker/company_fr.rb', line 23

def siren
  base = FFaker.numerify('########')
  base + luhn_check(base).to_s
end

#siretObject

Produces a company french siret number.



29
30
31
32
33
# File 'lib/ffaker/company_fr.rb', line 29

def siret
  location = rand(0..99).to_s.rjust(4, '0')
  org_no = siren + location
  org_no + luhn_check(org_no).to_s
end

#suffixObject



18
19
20
# File 'lib/ffaker/company_fr.rb', line 18

def suffix
  fetch_sample(SUFFIXES)
end