Class: Faker::Company
Constant Summary
Constants inherited from Base
Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters
Class Method Summary collapse
-
.australian_business_number ⇒ String
Produces a company australian business number.
-
.brazilian_company_number(legacy_formatted = NOT_GIVEN, formatted: false) ⇒ String
Produces a company brazilian company number.
-
.bs ⇒ String
Produces some company BS.
-
.buzzword ⇒ String
Produces a company buzzword.
-
.catch_phrase ⇒ String
Produces a company catch phrase.
-
.czech_organisation_number ⇒ String
Produces a company czech organisation number.
-
.duns_number ⇒ String
Produces a company duns number.
-
.ein ⇒ String
Produces a company EIN (Employer Identification Number).
-
.french_siren_number ⇒ String
Produces a company french siren number.
-
.french_siret_number ⇒ String
Produces a company french siret number.
-
.industry ⇒ String
Produces a company industry.
-
.logo ⇒ String
Produces a company logo.
-
.name ⇒ String
Produces a company name.
-
.norwegian_organisation_number ⇒ String
Produces a company norwegian organisation number.
-
.polish_register_of_national_economy(legacy_length = NOT_GIVEN, length: 9) ⇒ String
Produces a company polish register of national economy.
-
.polish_taxpayer_identification_number ⇒ String
Produces a company polish taxpayer identification_number.
-
.profession ⇒ String
Produces a company profession.
-
.russian_tax_number(region: nil, type: :legal) ⇒ Object
Get a random Russian tax number.
-
.sic_code ⇒ String
Produces a company sic code.
-
.south_african_close_corporation_registration_number ⇒ String
Produces a company south african close corporation registration number.
-
.south_african_listed_company_registration_number ⇒ String
Produces a company south african listed company registration number.
-
.south_african_pty_ltd_registration_number ⇒ String
Produces a company south african pty ltd registration number.
-
.south_african_trust_registration_number ⇒ String
Produces a company south african trust registration number.
-
.spanish_organisation_number ⇒ String
Produces a company spanish organisation number.
-
.suffix ⇒ String
Produces a company suffix.
-
.swedish_organisation_number ⇒ String
Produces a company swedish organisation number.
-
.type ⇒ String
Produces a company type.
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_number ⇒ String
Produces a company australian business number.
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.
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 |
.bs ⇒ String
Produces some company BS.
When a straight answer won't do, BS to the rescue!
83 84 85 |
# File 'lib/faker/default/company.rb', line 83 def bs translate('faker.company.bs').collect { |list| sample(list) }.join(' ') end |
.buzzword ⇒ String
Produces a company buzzword.
69 70 71 |
# File 'lib/faker/default/company.rb', line 69 def buzzword sample(translate('faker.company.buzzwords').flatten) end |
.catch_phrase ⇒ String
Produces a company catch phrase.
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_number ⇒ String
Produces a company czech organisation number.
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_number ⇒ String
Produces a company duns number.
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 |
.ein ⇒ String
Produces a company EIN (Employer Identification Number).
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_number ⇒ String
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
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_number ⇒ String
Produces a company french siret number.
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 |
.industry ⇒ String
Produces a company industry.
43 44 45 |
# File 'lib/faker/default/company.rb', line 43 def industry fetch('company.industry') end |
.logo ⇒ String
Produces a company logo.
Get a random company logo url in PNG format.
123 124 125 126 |
# File 'lib/faker/default/company.rb', line 123 def logo rand_num = rand(1..13) "https://pigment.github.io/fake-logos/logos/medium/color/#{rand_num}.png" end |
.name ⇒ String
Produces a company name.
17 18 19 |
# File 'lib/faker/default/company.rb', line 17 def name parse('company.name') end |
.norwegian_organisation_number ⇒ String
Produces a company norwegian organisation number.
Get a random Norwegian organization number. Info: www.brreg.no/om-oss/samfunnsoppdraget-vart/registera-vare/einingsregisteret/organisasjonsnummeret/
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
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_number ⇒ String
Produces a company polish taxpayer identification_number.
Get a random Polish taxpayer identification number More info pl.wikipedia.org/wiki/NIP
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 |
.profession ⇒ String
Produces a company profession.
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_code ⇒ String
Produces a company sic code.
414 415 416 |
# File 'lib/faker/default/company.rb', line 414 def sic_code fetch('company.sic_code') end |
.south_african_close_corporation_registration_number ⇒ String
Produces a company south african close corporation registration number.
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_number ⇒ String
Produces a company south african listed company registration number.
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_number ⇒ String
Produces a company south african pty ltd registration number.
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_number ⇒ String
Produces a company south african trust registration number.
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_number ⇒ String
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
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 |
.suffix ⇒ String
Produces a company suffix.
30 31 32 |
# File 'lib/faker/default/company.rb', line 30 def suffix fetch('company.suffix') end |
.swedish_organisation_number ⇒ String
Produces a company swedish organisation number.
Get a random Swedish organization number. See more here sv.wikipedia.org/wiki/Organisationsnummer
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 |
.type ⇒ String
Produces a company type.
137 138 139 |
# File 'lib/faker/default/company.rb', line 137 def type fetch('company.type') end |