convert code_insee to departement

This commit is contained in:
Christophe Robillard 2023-10-26 11:34:55 +02:00
parent 2b061dc2aa
commit 42d3052c4f
2 changed files with 23 additions and 0 deletions

14
app/lib/code_insee.rb Normal file
View file

@ -0,0 +1,14 @@
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