Modifies census_api to parse genre and dob
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user