File: identification_es_co.rb

package info (click to toggle)
ruby-ffaker 2.23.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,776 kB
  • sloc: ruby: 12,788; makefile: 8; sh: 1
file content (39 lines) | stat: -rw-r--r-- 809 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

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