Class: Faker::Company
Constant Summary
Constants inherited from Base
Base::Letters, Base::Numbers, Base::ULetters
Class Method Summary collapse
- .australian_business_number ⇒ Object
-
.bs ⇒ Object
When a straight answer won’t do, BS to the rescue!.
- .buzzword ⇒ Object
-
.catch_phrase ⇒ Object
Generate a buzzword-laden catch phrase.
- .czech_organisation_number ⇒ Object
- .duns_number ⇒ Object
- .ein ⇒ Object
-
.french_siren_number ⇒ Object
Get a random French SIREN number.
- .french_siret_number ⇒ Object
- .industry ⇒ Object
-
.logo ⇒ Object
Get a random company logo url in PNG format.
- .name ⇒ Object
-
.norwegian_organisation_number ⇒ Object
Get a random Norwegian organization number.
-
.polish_register_of_national_economy(length = 9) ⇒ Object
Get a random Polish register of national economy number.
-
.polish_taxpayer_identification_number ⇒ Object
Get a random Polish taxpayer identification number More info pl.wikipedia.org/wiki/NIP.
- .profession ⇒ Object
-
.spanish_organisation_number ⇒ Object
rubocop:disable Style/AsciiComments Get a random Spanish organization number.
- .suffix ⇒ Object
-
.swedish_organisation_number ⇒ Object
Get a random Swedish organization number.
- .type ⇒ Object
Methods inherited from Base
bothify, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, respond_to_missing?, sample, shuffle, translate, unique, with_locale
Class Method Details
.australian_business_number ⇒ Object
108 109 110 111 112 113 |
# File 'lib/faker/company.rb', line 108 def australian_business_number base = format('%09d', rand(10**9)) abn = "00#{base}" (99 - (abn_checksum(abn) % 89)).to_s + base end |
.bs ⇒ Object
When a straight answer won’t do, BS to the rescue!
28 29 30 |
# File 'lib/faker/company.rb', line 28 def bs translate('faker.company.bs').collect { |list| sample(list) }.join(' ') end |
.buzzword ⇒ Object
23 24 25 |
# File 'lib/faker/company.rb', line 23 def buzzword sample(translate('faker.company.buzzwords').flatten) end |
.catch_phrase ⇒ Object
Generate a buzzword-laden catch phrase.
19 20 21 |
# File 'lib/faker/company.rb', line 19 def catch_phrase translate('faker.company.buzzwords').collect { |list| sample(list) }.join(' ') end |
.czech_organisation_number ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/faker/company.rb', line 74 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 ⇒ Object
36 37 38 |
# File 'lib/faker/company.rb', line 36 def duns_number format('%09d', rand(10**9)).gsub(/(\d{2})(\d{3})(\d{4})/, '\\1-\\2-\\3') end |
.ein ⇒ Object
32 33 34 |
# File 'lib/faker/company.rb', line 32 def ein format('%09d', rand(10**9)).gsub(/(\d{2})(\d{7})/, '\\1-\\2') end |
.french_siren_number ⇒ Object
Get a random French SIREN number. See more here fr.wikipedia.org/wiki/Syst%C3%A8me_d%27identification_du_r%C3%A9pertoire_des_entreprises
86 87 88 89 |
# File 'lib/faker/company.rb', line 86 def french_siren_number base = (1..8).map { rand(10) }.join base + luhn_algorithm(base).to_s end |
.french_siret_number ⇒ Object
91 92 93 94 95 |
# File 'lib/faker/company.rb', line 91 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 ⇒ Object
14 15 16 |
# File 'lib/faker/company.rb', line 14 def industry fetch('company.industry') end |
.logo ⇒ Object
Get a random company logo url in PNG format.
41 42 43 44 |
# File 'lib/faker/company.rb', line 41 def logo rand_num = rand(1..13) "https://pigment.github.io/fake-logos/logos/medium/color/#{rand_num}.png" end |
.name ⇒ Object
6 7 8 |
# File 'lib/faker/company.rb', line 6 def name parse('company.name') end |
.norwegian_organisation_number ⇒ Object
Get a random Norwegian organization number. Info: www.brreg.no/om-oss/samfunnsoppdraget-vart/registera-vare/einingsregisteret/organisasjonsnummeret/
98 99 100 101 102 103 104 105 106 |
# File 'lib/faker/company.rb', line 98 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) ⇒ Object
Get a random Polish register of national economy number. More info pl.wikipedia.org/wiki/REGON
127 128 129 130 131 132 133 134 135 |
# File 'lib/faker/company.rb', line 127 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 ⇒ Object
Get a random Polish taxpayer identification number More info pl.wikipedia.org/wiki/NIP
116 117 118 119 120 121 122 123 124 |
# File 'lib/faker/company.rb', line 116 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 ⇒ Object
50 51 52 |
# File 'lib/faker/company.rb', line 50 def profession fetch('company.profession') end |
.spanish_organisation_number ⇒ Object
rubocop:disable Style/AsciiComments Get a random Spanish organization number. See more here es.wikipedia.org/wiki/Número_de_identificación_fiscal rubocop:enable Style/AsciiComments
57 58 59 60 61 62 63 |
# File 'lib/faker/company.rb', line 57 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 letters = %w[A B C D E F G H J N P Q R S U V W] base = [sample(letters), format('%07d', rand(10**7))].join base end |
.suffix ⇒ Object
10 11 12 |
# File 'lib/faker/company.rb', line 10 def suffix fetch('company.suffix') end |
.swedish_organisation_number ⇒ Object
Get a random Swedish organization number. See more here sv.wikipedia.org/wiki/Organisationsnummer
66 67 68 69 70 71 72 |
# File 'lib/faker/company.rb', line 66 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 ⇒ Object
46 47 48 |
# File 'lib/faker/company.rb', line 46 def type fetch('company.type') end |