Sha256: 1341c4f0422565cb492148b99831a94e770abdbd3ede07e07baf9e36e79fe910

Contents?: true

Size: 842 Bytes

Versions: 6

Compression:

Stored size: 842 Bytes

Contents

# frozen_string_literal: true

require 'ffaker/identification_es'
require 'date'

module FFaker
  module IdentificationESCO
    include IdentificationES

    extend ModuleUtils
    extend self

    BLOOD_TYPE = %w[A B O AB].freeze
    LICENSE_CATEGORY = %w[A B C].freeze

    def drivers_license
      how_many_numbers = rand(6..13)
      FFaker.numerify('#' * how_many_numbers)
    end

    alias id drivers_license

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

    def blood_type
      sign = fetch_sample(%w[+ -])
      "#{fetch_sample(BLOOD_TYPE)}#{sign}"
    end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ffaker-2.17.0 lib/ffaker/identification_es_co.rb
ffaker-2.16.0 lib/ffaker/identification_es_co.rb
ffaker-2.15.0 lib/ffaker/identification_es_co.rb
ffaker-2.14.0 lib/ffaker/identification_es_co.rb
ffaker-2.13.0 lib/ffaker/identification_es_co.rb
ffaker-2.12.0 lib/ffaker/identification_es_co.rb