Skip to content

Instantly share code, notes, and snippets.

@juliends
Created October 21, 2017 10:16
Show Gist options
  • Save juliends/7e42efa956b39ba446782171410d0f1e to your computer and use it in GitHub Desktop.
Save juliends/7e42efa956b39ba446782171410d0f1e to your computer and use it in GitHub Desktop.
user_from_githuv
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