Sha256: e1e76d525f6097a5646905306493e17e54e12f6db3656e3d7e0d698e5f444e24

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8

module Faker
  module Product
    extend ModuleUtils
    extend self

    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

    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

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

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

    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

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

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
ffaker-1.30.0 lib/ffaker/product.rb
ffaker-1.25.0 lib/ffaker/product.rb
ffaker-1.24.0 lib/ffaker/product.rb
ffakerer-1.0.2 lib/ffakerer/product.rb
ffaker-1.23.0 lib/ffaker/product.rb
ffakerer-1.0.1 lib/ffakerer/product.rb
ffaker-1.22.1 lib/ffaker/product.rb
ffaker-1.22.0 lib/ffaker/product.rb