PageRenderTime 205ms CodeModel.GetById 90ms app.highlight 12ms RepoModel.GetById 99ms 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
 3class DuckDuckGo
 4  include HTTParty
 5  base_uri 'api.duckduckgo.com'
 6
 7  def search(text)
 8    options = {:query => {:q => text.gsub(/-/, '+'), :format => 'json'}}
 9    response = self.class.get('/', options)
10    return response.code == 200 ? JSON.parse(response.body) : nil
11  end
12end