Class: Arbetsformedlingen::ExperienceRequiredCode

Inherits:
Object
  • Object
show all
Defined in:
lib/arbetsformedlingen/codes/experience_required_code.rb

Constant Summary collapse

CODES_MAP =
{
  'true' => '1',
  'false' => '4',
}.freeze
CODES_MAP_INVERTED =
CODES_MAP.invert.freeze

Class Method Summary collapse

Class Method Details

.to_code(value) ⇒ Object



13
14
15
16
17
# File 'lib/arbetsformedlingen/codes/experience_required_code.rb', line 13

def self.to_code(value)
  CODES_MAP.fetch(value.to_s) do
    value.to_s if CODES_MAP_INVERTED[value.to_s]
  end
end

.valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/arbetsformedlingen/codes/experience_required_code.rb', line 19

def self.valid?(value)
  !to_code(value).nil?
end