Sha256: 107e6ab94a9bfa7fdb6f5ece6d79fa59e5337404ee5ccdbbc29057272e9752c7

Contents?: true

Size: 808 Bytes

Versions: 5

Compression:

Stored size: 808 Bytes

Contents

# encoding: utf-8

require 'ffaker/identification_es'
require "date"

module Faker
  module IdentificationESCO
    include IdentificationES

    extend ModuleUtils
    extend self

    BLOOD_TYPE = %w(A B O AB)
    LICENSE_CATEGORY = %w(A B C)

    def drivers_license
      how_many_numbers = 6 + rand(8)
      Faker.numerify("#" * how_many_numbers)
    end

  alias_method :id, :drivers_license

    def driver_license_category
      category = LICENSE_CATEGORY.sample
      # the categories are A1 A2 B1 B2 B3 C1 C2 C3
      num = category == 'A' ? 1 + rand(2) : 1 + rand(3)
      "#{category}#{num}"
    end

    def blood_type #RH
      sign = %w(+ -).sample
      "#{BLOOD_TYPE.sample}#{sign}"
    end

    def expedition_date
      today = Date.today
      today - rand(today.year)
    end

  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/ffaker-1.32.1/lib/ffaker/identification_es_co.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/ffaker-1.32.1/lib/ffaker/identification_es_co.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/ffaker-1.32.1/lib/ffaker/identification_es_co.rb
ffaker-1.32.1 lib/ffaker/identification_es_co.rb
ffaker-1.32.0 lib/ffaker/identification_es_co.rb