Class: Basuco::Api
Constant Summary
Constants included from Request
Instance Method Summary collapse
- #api(options = {}) ⇒ Object
-
#initialize(options = {:host => 'http://www.freebase.com', :username => 'un', :password => 'pw'}) ⇒ Api
constructor
A new instance of Api.
Methods included from Request
#get_query_response, #handle_read_error, #http_request, #params_to_string, #service_url
Constructor Details
#initialize(options = {:host => 'http://www.freebase.com', :username => 'un', :password => 'pw'}) ⇒ Api
Returns a new instance of Api.
8 9 10 11 12 13 |
# File 'lib/basuco/api.rb', line 8 def initialize( = {:host => 'http://www.freebase.com', :username => 'un', :password => 'pw'}) @host = [:host] @username = [:username] @password = [:password] Basuco.api = self end |
Instance Method Details
#api(options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/basuco/api.rb', line 15 def api( = {}) .merge!({:query => query}) response = http_request search_service_url, result = JSON.parse response handle_read_error(result) result['result'] end |