Module: FFaker::Product

Extended by:
ModuleUtils, Product
Included in:
Product
Defined in:
lib/ffaker/product.rb

Constant Summary collapse

B2 =
%w(nix cell sync func balt sche pod)
VOWELS =
%w(a e i o u ou ie y io)
START =
%w(tr br p ph)
SUFFIX =
%w(ck ns nce nt st ne re ffe ph)
ADDON =
%w(wood forge func)

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore

Instance Method Details

#brandObject



14
15
16
17
18
19
20
# File 'lib/ffaker/product.rb', line 14

def brand
  case rand(12)
  when (0..4) then B1.sample + B2.sample
  when (5..10) then "#{START.sample}#{VOWELS.sample}#{SUFFIX.sample}#{ADDON.sample if rand(2) == 0}".capitalize
  when 11 then letters(2..3).to_s
  end
end

#letters(n) ⇒ Object



33
34
35
36
# File 'lib/ffaker/product.rb', line 33

def letters(n)
  max = n.is_a?(Range) ? n.to_a.sample : n
  (0...max).map { LETTERS.sample.upcase }.join
end

#modelObject



38
39
40
41
42
43
# File 'lib/ffaker/product.rb', line 38

def model
  case rand(2)
  when 0 then "#{LETTERS.sample.upcase}#{rand(90)}" # N90
  when 1 then "#{letters(1..rand(1..2))}-#{rand(9900)}" # N-9400
  end
end

#productObject



29
30
31
# File 'lib/ffaker/product.rb', line 29

def product
  "#{brand} #{product_name}"
end

#product_nameObject



22
23
24
25
26
27
# File 'lib/ffaker/product.rb', line 22

def product_name
  case rand(2)
  when 0 then "#{ADJ.sample} #{NOUN.sample}"
  when 1 then "#{[ADJ.sample, ADJ.sample].uniq.join(' ')} #{NOUN.sample}"
  end
end