Class: Ahiru::API

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

Constant Summary collapse

DUCKDUCKGO_ENDPOINT =
"https://duckduckgo.com/html/"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.search(params) ⇒ Object



19
20
21
# File 'lib/ahiru/api.rb', line 19

def self.search(params)
  new.search(params)
end

Instance Method Details

#search(q:, s: nil, dc: nil) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/ahiru/api.rb', line 11

def search(q:, s: nil, dc: nil)
  params = { q: q, s: s, dc: dc }.compact
  body = get_body(DUCKDUCKGO_ENDPOINT, params)
  return nil if body.nil?

  Page.new body
end