Created
December 16, 2011 04:45
-
-
Save adamdilek/1484514 to your computer and use it in GitHub Desktop.
Example RUBY Code for Name API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'json' | |
require 'net/http' | |
@base_url="http://pigon.ws/name/show?name=" | |
def find_name_gender(name) | |
url="#{@base_url}#{name}" | |
resp=Net::HTTP.get_response(URI.parse(url)) | |
data=resp.body | |
result=JSON.parse(data) | |
puts result['status'] | |
return result | |
end | |
input="" | |
until input == "exit" | |
puts "isim : " | |
input=gets.chomp | |
res = find_name_gender(input) | |
if res['gender'] == "M" | |
puts "#{input} Erkek ismi" | |
puts res['status'] | |
elsif res['gender'] == "F" | |
puts "#{input} Kadin ismi" | |
elsif res['gender'] == "B" | |
puts "#{input} Erkek-Kadin ismi" | |
else | |
puts res['error'] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment