Class: Faker::Company

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/default/company.rb

Constant Summary

Constants inherited from Base

Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale

Class Method Details

.australian_business_numberString

Produces a company australian business number.

Examples:

Faker::Company.australian_business_number #=> "93579396170"

Returns:

  • (String)

Available since:

  • 1.6.4


268
269
270
271
272
273
# File 'lib/faker/default/company.rb', line 268

def australian_business_number
  base = format('%09d', rand(10**9))
  abn = "00#{base}"

  (99 - (abn_checksum(abn) % 89)).to_s + base
end

.brazilian_company_number(legacy_formatted = NOT_GIVEN, formatted: false) ⇒ String

Produces a company brazilian company number.

Examples:

Faker::Company.brazilian_company_number #=> "37205322000500"

Returns:

  • (String)

Available since:

  • 1.9.2


381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/faker/default/company.rb', line 381

def brazilian_company_number(legacy_formatted = NOT_GIVEN, formatted: false)
  warn_for_deprecated_arguments do |keywords|
    keywords << :formatted if legacy_formatted != NOT_GIVEN
  end

  digits = Array.new(8) { Faker::Number.digit.to_i } + [0, 0, 0, Faker::Number.non_zero_digit.to_i]

  factors = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 6].cycle

  2.times do
    checksum = digits.inject(0) { |acc, digit| acc + digit * factors.next } % 11
    digits << (checksum < 2 ? 0 : 11 - checksum)
  end

  number = digits.join

  formatted ? format('%s.%s.%s/%s-%s', *number.scan(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/).flatten) : number
end

.bsString

Produces some company BS.

When a straight answer won't do, BS to the rescue!

Examples:

Faker::Company.bs #=> "empower customized functionalities"

Returns:

  • (String)

Available since:

  • 1.6.0


83
84
85
# File 'lib/faker/default/company.rb', line 83

def bs
  translate('faker.company.bs').collect { |list| sample(list) }.join(' ')
end

.buzzwordString

Produces a company buzzword.

Examples:

Faker::Company.buzzword #=> "flexibility"

Returns:

  • (String)

Available since:

  • 1.8.7


69
70
71
# File 'lib/faker/default/company.rb', line 69

def buzzword
  sample(translate('faker.company.buzzwords').flatten)
end

.catch_phraseString

Produces a company catch phrase.

Examples:

Faker::Company.catch_phrase #=> "Grass-roots grid-enabled portal"

Returns:

  • (String)

Available since:

  • 1.6.0


56
57
58
# File 'lib/faker/default/company.rb', line 56

def catch_phrase
  translate('faker.company.buzzwords').collect { |list| sample(list) }.join(' ')
end

.czech_organisation_numberString

Produces a company czech organisation number.

Examples:

Faker::Company.czech_organisation_number #=> "90642741"

Returns:

  • (String)

Available since:

  • 1.9.1


198
199
200
201
202
203
204
205
206
207
# File 'lib/faker/default/company.rb', line 198

def czech_organisation_number
  sum = 0
  base = []
  [8, 7, 6, 5, 4, 3, 2].each do |weight|
    base << sample((0..9).to_a)
    sum += (weight * base.last)
  end
  base << (11 - (sum % 11)) % 10
  base.join
end

.duns_numberString

Produces a company duns number.

Examples:

Faker::Company.duns_number #=> "70-655-5105"

Returns:

  • (String)

Available since:

  • 1.6.0


109
110
111
# File 'lib/faker/default/company.rb', line 109

def duns_number
  format('%09d', rand(10**9)).gsub(/(\d{2})(\d{3})(\d{4})/, '\\1-\\2-\\3')
end

.einString

Produces a company EIN (Employer Identification Number).

Examples:

Faker::Company.ein #=> "07-4009024"

Returns:

  • (String)

Available since:

  • 1.6.0


96
97
98
# File 'lib/faker/default/company.rb', line 96

def ein
  format('%09d', rand(10**9)).gsub(/(\d{2})(\d{7})/, '\\1-\\2')
end

.french_siren_numberString

Produces a company french siren number.

Get a random French SIREN number. See more here fr.wikipedia.org/wiki/Syst%C3%A8me_d%27identification_du_r%C3%A9pertoire_des_entreprises

Examples:

Faker::Company.french_siren_number #=> "163417827"

Returns:

  • (String)

Available since:

  • 1.8.5


219
220
221
222
# File 'lib/faker/default/company.rb', line 219

def french_siren_number
  base = (1..8).map { rand(10) }.join
  base + luhn_algorithm(base).to_s
end

.french_siret_numberString

Produces a company french siret number.

Examples:

Faker::Company.french_siret_number #=> "76430067900496"

Returns:

  • (String)

Available since:

  • 1.8.5


233
234
235
236
237
# File 'lib/faker/default/company.rb', line 233

def french_siret_number
  location = rand(100).to_s.rjust(4, '0')
  org_no = french_siren_number + location
  org_no + luhn_algorithm(org_no).to_s
end

.industryString

Produces a company industry.

Examples:

Faker::Company.industry #=> "Food & Beverages"

Returns:

  • (String)

Available since:

  • 1.6.0


43
44
45
# File 'lib/faker/default/company.rb', line 43

def industry
  fetch('company.industry')
end

.logoString

Produces a company logo.

Get a random company logo url in PNG format.

Examples:

Faker::Company. #=> "https://pigment.github.io/fake-logos/logos/medium/color/12.png"

Returns:

  • (String)

Available since:

  • 1.8.7


123
124
125
126
# File 'lib/faker/default/company.rb', line 123

def 
  rand_num = rand(1..13)
  "https://pigment.github.io/fake-logos/logos/medium/color/#{rand_num}.png"
end

.nameString

Produces a company name.

Examples:

Faker::Company.name #=> "Roberts Inc"

Returns:

  • (String)

Available since:

  • 1.6.0


17
18
19
# File 'lib/faker/default/company.rb', line 17

def name
  parse('company.name')
end

.norwegian_organisation_numberString

Produces a company norwegian organisation number.

Get a random Norwegian organization number. Info: www.brreg.no/om-oss/samfunnsoppdraget-vart/registera-vare/einingsregisteret/organisasjonsnummeret/

Examples:

Faker::Company.norwegian_organisation_number #=> "842457173"

Returns:

  • (String)

Available since:

  • 1.8.0


249
250
251
252
253
254
255
256
257
# File 'lib/faker/default/company.rb', line 249

def norwegian_organisation_number
  # Valid leading digit: 8, 9
  mod11_check = nil
  while mod11_check.nil?
    base = [sample([8, 9]), format('%07d', rand(10**7))].join
    mod11_check = mod11(base)
  end
  base + mod11_check.to_s
end

.polish_register_of_national_economy(legacy_length = NOT_GIVEN, length: 9) ⇒ String

Produces a company polish register of national economy.

Get a random Polish register of national economy number. More info pl.wikipedia.org/wiki/REGON

Examples:

Faker::Company.polish_register_of_national_economy #=> "788435970"

Returns:

  • (String)

Raises:

  • (ArgumentError)

Available since:

  • 1.9.1


305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/faker/default/company.rb', line 305

def polish_register_of_national_economy(legacy_length = NOT_GIVEN, length: 9)
  warn_for_deprecated_arguments do |keywords|
    keywords << :length if legacy_length != NOT_GIVEN
  end

  raise ArgumentError, 'Length should be 9 or 14' unless [9, 14].include? length

  random_digits = []
  loop do
    random_digits = Array.new(length) { rand(10) }
    break if collect_regon_sum(random_digits) == random_digits.last
  end
  random_digits.join('')
end

.polish_taxpayer_identification_numberString

Produces a company polish taxpayer identification_number.

Get a random Polish taxpayer identification number More info pl.wikipedia.org/wiki/NIP

Examples:

Faker::Company.polish_taxpayer_identification_number #=> "2767549463"

Returns:

  • (String)

Available since:

  • 1.9.1


285
286
287
288
289
290
291
292
293
# File 'lib/faker/default/company.rb', line 285

def polish_taxpayer_identification_number
  result = []
  weights = [6, 5, 7, 2, 3, 4, 5, 6, 7]
  loop do
    result = Array.new(3) { rand(1..9) } + Array.new(7) { rand(10) }
    break if (weight_sum(result, weights) % 11) == result[9]
  end
  result.join('')
end

.professionString

Produces a company profession.

Examples:

Faker::Company.profession #=> "factory worker"

Returns:

  • (String)

Available since:

  • 1.6.0


150
151
152
# File 'lib/faker/default/company.rb', line 150

def profession
  fetch('company.profession')
end

.russian_tax_number(region: nil, type: :legal) ⇒ Object

Get a random Russian tax number.


401
402
403
# File 'lib/faker/default/company.rb', line 401

def russian_tax_number(region: nil, type: :legal)
  inn_number(region, type)
end

.sic_codeString

Produces a company sic code.

Examples:

Faker::Company.sic_code #=> "7383"

Returns:

  • (String)

Available since:

  • 1.9.4


414
415
416
# File 'lib/faker/default/company.rb', line 414

def sic_code
  fetch('company.sic_code')
end

.south_african_close_corporation_registration_numberString

Produces a company south african close corporation registration number.

Examples:

Faker::Company.south_african_close_corporation_registration_number #=> "CK38/5739937418/23"

Returns:

  • (String)

Available since:

  • 1.9.2


342
343
344
# File 'lib/faker/default/company.rb', line 342

def south_african_close_corporation_registration_number
  regexify(/(CK\d{2}|\d{4})\/\d{4,10}\/23/)
end

.south_african_listed_company_registration_numberString

Produces a company south african listed company registration number.

Examples:

Faker::Company.south_african_listed_company_registration_number #=> "2512/87676/06"

Returns:

  • (String)

Available since:

  • 1.9.2


355
356
357
# File 'lib/faker/default/company.rb', line 355

def south_african_listed_company_registration_number
  regexify(/\d{4}\/\d{4,10}\/06/)
end

.south_african_pty_ltd_registration_numberString

Produces a company south african pty ltd registration number.

Examples:

Faker::Company.south_african_pty_ltd_registration_number #=> "7043/2400717902/07"

Returns:

  • (String)

Available since:

  • 1.9.2


329
330
331
# File 'lib/faker/default/company.rb', line 329

def south_african_pty_ltd_registration_number
  regexify(/\d{4}\/\d{4,10}\/07/)
end

.south_african_trust_registration_numberString

Produces a company south african trust registration number.

Examples:

Faker::Company.south_african_trust_registration_number #=> "IT5673/937519896"

Returns:

  • (String)

Available since:

  • 1.9.2


368
369
370
# File 'lib/faker/default/company.rb', line 368

def south_african_trust_registration_number
  regexify(/IT\d{2,4}\/\d{2,10}/)
end

.spanish_organisation_numberString

Produces a company spanish organisation number.

Get a random Spanish organization number. See more here es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal

Examples:

Faker::Company.spanish_organisation_number #=> "D6819358"

Returns:

  • (String)

Available since:

  • 1.8.5


165
166
167
168
169
# File 'lib/faker/default/company.rb', line 165

def spanish_organisation_number
  # Valid leading character: A, B, C, D, E, F, G, H, J, N, P, Q, R, S, U, V, W
  # 7 digit numbers
  [sample(self::ULetters), format('%07d', rand(10**7))].join
end

.suffixString

Produces a company suffix.

Examples:

Faker::Company.suffix #=> "LLC"

Returns:

  • (String)

Available since:

  • 1.6.0


30
31
32
# File 'lib/faker/default/company.rb', line 30

def suffix
  fetch('company.suffix')
end

.swedish_organisation_numberString

Produces a company swedish organisation number.

Get a random Swedish organization number. See more here sv.wikipedia.org/wiki/Organisationsnummer

Examples:

Faker::Company.swedish_organisation_number #=> "3866029808"

Returns:

  • (String)

Available since:

  • 1.7.0


181
182
183
184
185
186
187
# File 'lib/faker/default/company.rb', line 181

def swedish_organisation_number
  # Valid leading digit: 1, 2, 3, 5, 6, 7, 8, 9
  # Valid third digit: >= 2
  # Last digit is a control digit
  base = [sample([1, 2, 3, 5, 6, 7, 8, 9]), sample((0..9).to_a), sample((2..9).to_a), format('%06d', rand(10**6))].join
  base + luhn_algorithm(base).to_s
end

.typeString

Produces a company type.

Examples:

Faker::Company.type #=> "Partnership"

Returns:

  • (String)

Available since:

  • 1.8.7


137
138
139
# File 'lib/faker/default/company.rb', line 137

def type
  fetch('company.type')
end