demarches-normaliennes/app/lib/code_insee.rb

17 lines
261 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2023-10-26 11:34:55 +02:00
class CodeInsee
def initialize(code_insee)
@code_insee = code_insee
end
def to_departement
dept = @code_insee.strip.first(2)
if dept < "97"
dept
else
@code_insee.strip.first(3)
end
end
end