Module: Arbetsformedlingen::DriversLicenseCode
- Defined in:
- lib/arbetsformedlingen/codes/drivers_license_code.rb
Constant Summary collapse
- CODES =
Set.new([ 'AM', 'A1', 'A2', 'A', 'B', 'Utökad B', 'BE', 'C1', 'C1E', 'C', 'CE', 'D1', 'D1E', 'D', 'DE' ]).freeze
Class Method Summary collapse
- .codes ⇒ Object
- .normalize(drivers_license) ⇒ Object
- .to_a(drivers_license) ⇒ Object
- .to_code(drivers_license) ⇒ Object
- .valid?(drivers_license) ⇒ Boolean
Class Method Details
.codes ⇒ Object
12 13 14 |
# File 'lib/arbetsformedlingen/codes/drivers_license_code.rb', line 12 def self.codes CODES.to_a end |
.normalize(drivers_license) ⇒ Object
24 25 26 |
# File 'lib/arbetsformedlingen/codes/drivers_license_code.rb', line 24 def self.normalize(drivers_license) to_a(drivers_license).join(',') end |
.to_a(drivers_license) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/arbetsformedlingen/codes/drivers_license_code.rb', line 28 def self.to_a(drivers_license) drivers_license.to_s. split(','). map(&:strip). reject(&:empty?). map(&:upcase) end |
.to_code(drivers_license) ⇒ Object
16 17 18 |
# File 'lib/arbetsformedlingen/codes/drivers_license_code.rb', line 16 def self.to_code(drivers_license) normalize(drivers_license) end |
.valid?(drivers_license) ⇒ Boolean
20 21 22 |
# File 'lib/arbetsformedlingen/codes/drivers_license_code.rb', line 20 def self.valid?(drivers_license) to_a(drivers_license).all? { |dl| CODES.include?(dl) } end |