Class: WhatIMean::Google

Inherits:
Object
  • Object
show all
Defined in:
lib/whatimean/google.rb

Constant Summary collapse

BASE_URL =

Url to Google Custom Search API

'https://www.googleapis.com/customsearch/v1?cref&key={key}&q={word}'

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Google

Instantiate a new Google client object

Parameters:

  • key (String)

    Google Console Custom Search API KEY



13
14
15
# File 'lib/whatimean/google.rb', line 13

def initialize(key)
  @key = key
end

Instance Method Details

#search(word) ⇒ Word

Searchs a string with Google Custom Search

Parameters:

  • word (String)

Returns:



20
21
22
# File 'lib/whatimean/google.rb', line 20

def search(word)
  WhatIMean::Word.new(name: word, hits: fetch_word(word))
end