Class: FindKeywords::Keywords

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sentence, word_list = "stop_words") ⇒ Keywords

Returns a new instance of Keywords.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/find_keywords.rb', line 11

def initialize (sentence, word_list = "stop_words")
  if sentence.is_a?(String)
    @sentence = sentence
  elsif sentence.is_a?(Array)
    @sentence = sentence.join(' ')
  elsif sentence.is_a?(Hash)
    @sentence = sentence.collect { |k, v| "#{k} #{v} " }.join
  else
    @sentence = ''
  end
  @keywords = find_keywords(@sentence, word_list)
end

Instance Attribute Details

#keywordsObject (readonly)

Returns the value of attribute keywords.



9
10
11
# File 'lib/find_keywords.rb', line 9

def keywords
  @keywords
end

#sentenceObject

Returns the value of attribute sentence.



8
9
10
# File 'lib/find_keywords.rb', line 8

def sentence
  @sentence
end