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(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.
-
.department ⇒ String
Produces a company department.
-
.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.
-
.indian_gst_number(state_code: nil) ⇒ String
Get a random Indian Goods and Services Tax (GST) 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(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) ⇒ String
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(organization_type: nil) ⇒ 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, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, shuffle!, translate, unique, with_locale
Class Method Details
.australian_business_number ⇒ String
Produces a company australian business number.
288 289 290 291 292 293 |
# File 'lib/faker/default/company.rb', line 288 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(formatted: false) ⇒ String
Produces a company brazilian company number.
423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
# File 'lib/faker/default/company.rb', line 423 def brazilian_company_number(formatted: false) 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.
218 219 220 221 222 223 224 225 226 227 |
# File 'lib/faker/default/company.rb', line 218 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 |
.department ⇒ String
Produces a company department.
163 164 165 |
# File 'lib/faker/default/company.rb', line 163 def department fetch('company.department') 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
239 240 241 242 |
# File 'lib/faker/default/company.rb', line 239 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.
253 254 255 256 257 |
# File 'lib/faker/default/company.rb', line 253 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 |
.indian_gst_number(state_code: nil) ⇒ String
Get a random Indian Goods and Services Tax (GST) number. For more on Indian tax number here: simple.wikipedia.org/wiki/GSTIN
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
# File 'lib/faker/default/company.rb', line 479 def indian_gst_number(state_code: nil) # Check if state code is valid state_code_ranges = [('02'..'38'), ['98']] if state_code && !(state_code_ranges[0].include?(state_code) || state_code == '98') raise ArgumentError, 'state code must be in a range of 02 to 38 or 98' end PositionalGenerator.new(:string) do |gen| # Generate a state code if not given if state_code gen.lit(state_code, name: :state_code_param) else gen.letter(name: :state_code_param, length: 1, ranges: state_code_ranges) end # Construct taxpayer number gen.group(name: :taxpayer_number) do |g_| g_.letter(length: 3, ranges: ['A'..'Z']) g_.letter(length: 1, ranges: [%w[A B C F G H L J P T K]].to_a) g_.letter(length: 1, ranges: ['A'..'Z']) g_.int(length: 4, ranges: [0..9999]) g_.letter(length: 1, ranges: ['A'..'Z']) end gen.int(name: :registration_number, length: 1, ranges: [0..9]) gen.letter(name: :z_char, length: 1, ranges: [['Z']]) gen.computed(deps: %i[state_code_param taxpayer_number registration_number]) do |state_code_param, taxpayer_number, registration_number| gst_base = "#{state_code_param}#{taxpayer_number}#{registration_number}" chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.chars values = gst_base.chars sum = values.map.with_index do |char, index| product = chars.index(char) * (index.odd? ? 2 : 1) (product / chars.length).floor + (product % chars.length) end.reduce(:+) checksum = (chars.length - (sum % chars.length)) % chars.length chars[checksum] end end.generate 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/
269 270 271 272 273 274 275 276 277 |
# File 'lib/faker/default/company.rb', line 269 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(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
325 326 327 328 329 330 331 332 333 334 |
# File 'lib/faker/default/company.rb', line 325 def polish_register_of_national_economy(length: 9) 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
305 306 307 308 309 310 311 312 313 |
# File 'lib/faker/default/company.rb', line 305 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) ⇒ String
Get a random Russian tax number.
450 451 452 |
# File 'lib/faker/default/company.rb', line 450 def russian_tax_number(region: nil, type: :legal) inn_number(region, type) end |
.sic_code ⇒ String
Produces a company sic code.
463 464 465 |
# File 'lib/faker/default/company.rb', line 463 def sic_code fetch('company.sic_code') end |
.south_african_close_corporation_registration_number ⇒ String
Produces a company south african close corporation registration number.
363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/faker/default/company.rb', line 363 def south_african_close_corporation_registration_number generate(:string) do |g| g.oneof do |one| one.group do |g_| g_.lit('CK') g_.int(length: 2) end one.int(length: 4) end g.lit('/') g.int(ranges: [1000..9_999_999_999]) g.lit('/23') end end |
.south_african_listed_company_registration_number ⇒ String
Produces a company south african listed company registration number.
387 388 389 390 391 392 393 394 |
# File 'lib/faker/default/company.rb', line 387 def south_african_listed_company_registration_number generate(:string) do |g| g.int(length: 4) g.lit('/') g.int(ranges: [1000..9_999_999_999]) g.lit('/06') end end |
.south_african_pty_ltd_registration_number ⇒ String
Produces a company south african pty ltd registration number.
345 346 347 348 349 350 351 352 |
# File 'lib/faker/default/company.rb', line 345 def south_african_pty_ltd_registration_number generate(:string) do |g| g.int(length: 4) g.lit('/') g.int(ranges: [1000..9_999_999_999]) g.lit('/07') end end |
.south_african_trust_registration_number ⇒ String
Produces a company south african trust registration number.
405 406 407 408 409 410 411 412 |
# File 'lib/faker/default/company.rb', line 405 def south_african_trust_registration_number generate(:string) do |g| g.lit('IT') g.int(ranges: [10..9999]) g.lit('/') g.int(ranges: [10..9_999_999_999]) end end |
.spanish_organisation_number(organization_type: nil) ⇒ 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
178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/faker/default/company.rb', line 178 def spanish_organisation_number(organization_type: nil) # Valid leading character: A, B, C, D, E, F, G, H, J, N, P, Q, R, S, U, V, W # format: 1 digit letter (organization type) + 7 digit numbers + 1 digit control (letter or number based on # organization type) letters = %w[A B C D E F G H J N P Q R S U V W] organization_type = sample(letters) unless letters.include?(organization_type) code = format('%07d', rand(10**7)) control = spanish_cif_control_digit(organization_type, code) [organization_type, code, control].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
201 202 203 204 205 206 207 |
# File 'lib/faker/default/company.rb', line 201 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 |