Modifies census_api to parse genre and dob

This commit is contained in:
kikito
2016-04-12 18:18:25 +02:00
parent 0ae97eada8
commit 4f724ef3bf
2 changed files with 12 additions and 4 deletions

View File

@@ -38,7 +38,10 @@ class CensusApi
end
def date_of_birth
data[:datos_habitante][:item][:fecha_nacimiento_string]
str = data[:datos_habitante][:item][:fecha_nacimiento_string]
day, month, year = str.match(/(\d\d?)\D(\d\d?)\D(\d\d\d?\d?)/)[1..3]
return nil unless day.present? && month.present? && year.present?
Date.new(year.to_i, month.to_i, day.to_i)
end
def postal_code
@@ -50,7 +53,12 @@ class CensusApi
end
def genre # "Varón" or "Mujer"
data[:datos_habitante][:item][:descripcion_sexo]
case data[:datos_habitante][:item][:descripcion_sexo]
when "Varón"
"male"
when "Mujer"
"female"
end
end
private