Class: Basuco::Api

Inherits:
Object
  • Object
show all
Includes:
Request
Defined in:
lib/basuco/api.rb

Constant Summary

Constants included from Request

Request::SERVICES

Instance Method Summary collapse

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(options = {:host => 'http://www.freebase.com', :username => 'un', :password => 'pw'})
  @host = options[:host]
  @username = options[:username]
  @password = options[: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(options = {})
  options.merge!({:query => query})
  
  response = http_request search_service_url, options
  result = JSON.parse response
  
  handle_read_error(result)
  
  result['result']
end