module Faker::Product

Constants

ADDON
B2
START
SUFFIX
VOWELS

Public Instance Methods

brand() click to toggle source
# File lib/ffakerer/product.rb, line 8
def brand
  case rand(12)
  when (0..4) then B1.rand + B2.rand
  when (5..10) then "#{START.rand}#{VOWELS.rand}#{SUFFIX.rand}#{ADDON.rand if rand(2)==0}".capitalize
  when 11 then "#{letters(2..3)}"
  end
end
letters(n) click to toggle source
# File lib/ffakerer/product.rb, line 27
def letters(n)
  max = n.is_a?(Range) ? n.to_a.shuffle.first : n
  (0...max).map { LETTERS.rand.upcase }.join
end
model() click to toggle source
# File lib/ffakerer/product.rb, line 32
def model
  case rand(2)
  when 0 then "#{LETTERS.rand.upcase}#{rand(90)}"   # N90
  when 1 then "#{letters(1..rand(1..2))}-#{rand(9900)}"         # N-9400
  end
end
product() click to toggle source
# File lib/ffakerer/product.rb, line 23
def product
  "#{brand} #{product_name}"
end
product_name() click to toggle source
# File lib/ffakerer/product.rb, line 16
def product_name
  case rand(2)
  when 0 then "#{ADJ.rand} #{NOUN.rand}"
  when 1 then "#{[ADJ.rand, ADJ.rand].uniq.join(" ")} #{NOUN.rand}"
  end
end