Created
October 21, 2017 10:16
-
-
Save juliends/7e42efa956b39ba446782171410d0f1e to your computer and use it in GitHub Desktop.
user_from_githuv
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 "open-uri" | |
require "json" | |
puts "What is your Github nickname ?" | |
print "> " | |
username = gets.chomp | |
url = "https://api.github.com/users/#{username}" | |
# calls the api | |
response = open(url).read | |
# parse the json response to build a ruby hash | |
user = JSON.parse(response) | |
name = user["name"] | |
location = user["location"] | |
puts "#{name} lives in #{location}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment