Class: Basuco::Api

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {:host => 'http://www.freebase.com', :username => 'un', :password => 'pw'}) ⇒ Api

Returns a new instance of Api.



7
8
9
10
11
12
# File 'lib/basuco/api.rb', line 7

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



14
15
16
17
18
19
20
21
22
23
# File 'lib/basuco/api.rb', line 14

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