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