demarches-normaliennes/app/lib/code_insee.rb

15 lines
230 B
Ruby
Raw Normal View History

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