Module: Faker::Product
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
const_missing, k, underscore
Instance Method Details
#brand ⇒ Object
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)}"
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.shuffle.first : n
(0...max).map { LETTERS.sample.upcase }.join
end
|
#model ⇒ Object
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)}"
when 1 then "#{letters(1..rand(1..2))}-#{rand(9900)}"
end
end
|
#product ⇒ Object
29
30
31
|
# File 'lib/ffaker/product.rb', line 29
def product
"#{brand} #{product_name}"
end
|
#product_name ⇒ Object
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
|