Created
December 22, 2011 16:40
-
-
Save adamdilek/1510934 to your computer and use it in GitHub Desktop.
RUBY Example for University 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' | |
require 'uri' | |
def get(base_url) | |
url="#{base_url}" | |
response=Net::HTTP.get_response(URI.parse(url)) | |
data=response.body | |
result=JSON.parse(data) | |
puts response.code[0] | |
return result | |
end | |
@universites = get("http://pigon.ws/university/list") | |
@universites.each do |university| | |
puts university['name'] | |
@faculties=get("http://pigon.ws/university/faculties/?university_id=#{university['id']}") | |
@faculties.each do |faculty| | |
puts "--#{faculty['name']}" | |
@departments=get("http://pigon.ws/university/departments/?faculty_id=#{faculty['id']}") | |
@departments.each do |department| | |
puts "----#{department['name']}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment