Class: Basuco::Api
- Inherits:
-
Object
- Object
- Basuco::Api
- Defined in:
- lib/basuco/api.rb
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.
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( = {: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
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/basuco/api.rb', line 14 def api( = {}) .merge!({:query => query}) response = http_request search_service_url, result = JSON.parse response handle_read_error(result) result['result'] end |