lib/gendered/guesser.rb in gendered-0.0.5 vs lib/gendered/guesser.rb in gendered-0.0.7
- old
+ new
@@ -18,11 +18,16 @@
guesses = JSON.parse(response.body)
names.collect do |name|
name = Name.new(name) if name.is_a?(String)
- guess = guesses.find { |g| g["name"] == name.value }
+ guess = case
+ when guesses.is_a?(Array)
+ guesses.find { |g| g["name"] == name.value }
+ else
+ guesses
+ end
if guess["gender"]
name.gender = guess["gender"].to_sym
name.probability = guess["probability"]
name.sample_size = guess["count"]
@@ -32,10 +37,10 @@
end
end
end
def url
- url = "http://api.genderize.io/?"
+ url = "https://api.genderize.io/?"
url += "country_id=#{country_id}&" if country_id
name_queries = names.collect.with_index do |name, index|
"name[#{index}]=#{CGI.escape(name.to_s)}"
end