Class: Faker::Company
- Inherits:
-
Base
- Object
- Base
- Faker::Company
show all
- Defined in:
- lib/faker/default/company.rb
Constant Summary
Constants inherited
from Base
Base::Letters, 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_number ⇒ Object
110
111
112
113
114
115
|
# File 'lib/faker/default/company.rb', line 110
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) ⇒ Object
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
# File 'lib/faker/default/company.rb', line 156
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 ⇒ Object
When a straight answer won’t do, BS to the rescue!
30
31
32
|
# File 'lib/faker/default/company.rb', line 30
def bs
translate('faker.company.bs').collect { |list| sample(list) }.join(' ')
end
|
.buzzword ⇒ Object
25
26
27
|
# File 'lib/faker/default/company.rb', line 25
def buzzword
sample(translate('faker.company.buzzwords').flatten)
end
|
.catch_phrase ⇒ Object
Generate a buzzword-laden catch phrase.
21
22
23
|
# File 'lib/faker/default/company.rb', line 21
def catch_phrase
translate('faker.company.buzzwords').collect { |list| sample(list) }.join(' ')
end
|
.czech_organisation_number ⇒ Object
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/faker/default/company.rb', line 76
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
38
39
40
|
# File 'lib/faker/default/company.rb', line 38
def duns_number
format('%09d', rand(10**9)).gsub(/(\d{2})(\d{3})(\d{4})/, '\\1-\\2-\\3')
end
|
.ein ⇒ Object
34
35
36
|
# File 'lib/faker/default/company.rb', line 34
def ein
format('%09d', rand(10**9)).gsub(/(\d{2})(\d{7})/, '\\1-\\2')
end
|
.french_siren_number ⇒ Object
88
89
90
91
|
# File 'lib/faker/default/company.rb', line 88
def french_siren_number
base = (1..8).map { rand(10) }.join
base + luhn_algorithm(base).to_s
end
|
.french_siret_number ⇒ Object
93
94
95
96
97
|
# File 'lib/faker/default/company.rb', line 93
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
16
17
18
|
# File 'lib/faker/default/company.rb', line 16
def industry
fetch('company.industry')
end
|
.logo ⇒ Object
Get a random company logo url in PNG format.
43
44
45
46
|
# File 'lib/faker/default/company.rb', line 43
def logo
rand_num = rand(1..13)
"https://pigment.github.io/fake-logos/logos/medium/color/#{rand_num}.png"
end
|
.name ⇒ Object
8
9
10
|
# File 'lib/faker/default/company.rb', line 8
def name
parse('company.name')
end
|
.norwegian_organisation_number ⇒ Object
100
101
102
103
104
105
106
107
108
|
# File 'lib/faker/default/company.rb', line 100
def norwegian_organisation_number
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
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/faker/default/company.rb', line 129
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
118
119
120
121
122
123
124
125
126
|
# File 'lib/faker/default/company.rb', line 118
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
52
53
54
|
# File 'lib/faker/default/company.rb', line 52
def profession
fetch('company.profession')
end
|
.south_african_close_corporation_registration_number ⇒ Object
144
145
146
|
# File 'lib/faker/default/company.rb', line 144
def south_african_close_corporation_registration_number
regexify(/(CK\d{2}|\d{4})\/\d{4,10}\/23/)
end
|
.south_african_listed_company_registration_number ⇒ Object
148
149
150
|
# File 'lib/faker/default/company.rb', line 148
def south_african_listed_company_registration_number
regexify(/\d{4}\/\d{4,10}\/06/)
end
|
.south_african_pty_ltd_registration_number ⇒ Object
140
141
142
|
# File 'lib/faker/default/company.rb', line 140
def south_african_pty_ltd_registration_number
regexify(/\d{4}\/\d{4,10}\/07/)
end
|
.south_african_trust_registration_number ⇒ Object
152
153
154
|
# File 'lib/faker/default/company.rb', line 152
def south_african_trust_registration_number
regexify(/IT\d{2,4}\/\d{2,10}/)
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
59
60
61
62
63
64
65
|
# File 'lib/faker/default/company.rb', line 59
def spanish_organisation_number
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
12
13
14
|
# File 'lib/faker/default/company.rb', line 12
def suffix
fetch('company.suffix')
end
|
.swedish_organisation_number ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/faker/default/company.rb', line 68
def swedish_organisation_number
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
48
49
50
|
# File 'lib/faker/default/company.rb', line 48
def type
fetch('company.type')
end
|