convert code_insee to departement
This commit is contained in:
parent
2b061dc2aa
commit
42d3052c4f
2 changed files with 23 additions and 0 deletions
14
app/lib/code_insee.rb
Normal file
14
app/lib/code_insee.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue