Class: Faker::Company

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

Constant Summary

Constants inherited from Base

Base::Letters, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

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

Class Method Details

.australian_business_numberObject


87
88
89
90
91
92
# File 'lib/faker/company.rb', line 87

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

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

.bsObject

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

.buzzwordObject


23
24
25
# File 'lib/faker/company.rb', line 23

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

.catch_phraseObject

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

.duns_numberObject


36
37
38
# File 'lib/faker/company.rb', line 36

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

.einObject


32
33
34
# File 'lib/faker/company.rb', line 32

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

.french_siren_numberObject


65
66
67
68
# File 'lib/faker/company.rb', line 65

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

.french_siret_numberObject


70
71
72
73
74
# File 'lib/faker/company.rb', line 70

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

.industryObject


14
15
16
# File 'lib/faker/company.rb', line 14

def industry
  fetch('company.industry')
end

.logoObject

Get a random company logo url in PNG format.


41
42
43
44
# File 'lib/faker/company.rb', line 41

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

.nameObject


6
7
8
# File 'lib/faker/company.rb', line 6

def name
  parse('company.name')
end

.norwegian_organisation_numberObject


77
78
79
80
81
82
83
84
85
# File 'lib/faker/company.rb', line 77

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

.professionObject


94
95
96
# File 'lib/faker/company.rb', line 94

def profession
  fetch('company.profession')
end

.spanish_organisation_numberObject

Get a random Spanish organization number. See more here es.wikipedia.org/wiki/Número_de_identificación_fiscal


47
48
49
50
51
52
53
# File 'lib/faker/company.rb', line 47

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 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'N', 'P', 'Q', 'R', 'S', 'U', 'V', 'W']
  base = [sample(letters), ('%07d' % rand(10 ** 7))].join
  base
end

.suffixObject


10
11
12
# File 'lib/faker/company.rb', line 10

def suffix
  fetch('company.suffix')
end

.swedish_organisation_numberObject

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


56
57
58
59
60
61
62
# File 'lib/faker/company.rb', line 56

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), ('%06d' % rand(10 ** 6))].join
  base + luhn_algorithm(base).to_s
end