PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/api/duckduckgo.com.rb

https://bitbucket.org/andey/bestofama
Ruby | 12 lines | 9 code | 2 blank | 1 comment | 1 complexity | a121a8c9f253a04917c7c5359c9c1cbe MD5 | raw file
  1. #== DuckDuckGo Stats API library
  2. class DuckDuckGo
  3. include HTTParty
  4. base_uri 'api.duckduckgo.com'
  5. def search(text)
  6. options = {:query => {:q => text.gsub(/-/, '+'), :format => 'json'}}
  7. response = self.class.get('/', options)
  8. return response.code == 200 ? JSON.parse(response.body) : nil
  9. end
  10. end