Class: WhatIMean::Find

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

Overview

Find

The Core of WhatIMean, this class interacts with Google and Word and fetch the search returning each word with hits, name and rate comparison

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, *words) ⇒ Find

Compare strings and return a list ordered by occurence

Parameters:

  • client (Google)

    The WhatIMean::Google client

  • words (Array<String>)

    The words to be compared



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

def initialize(client, *words)
  @client = client
  @words = fetch_words(words).sort { |x,y| y.hits <=> x.hits }
end

Instance Attribute Details

#wordsObject (readonly)

Returns the value of attribute words.



6
7
8
# File 'lib/whatimean/find.rb', line 6

def words
  @words
end

Instance Method Details

#winnerWord

Returns the word in comparison with most results

Returns:

  • (Word)

    The winner with most occurences



19
20
21
# File 'lib/whatimean/find.rb', line 19

def winner
  @words.first
end