Class: FindKeywords::Keywords
- Inherits:
-
Object
- Object
- FindKeywords::Keywords
- Defined in:
- lib/find_keywords.rb
Instance Attribute Summary collapse
-
#keywords ⇒ Object
readonly
Returns the value of attribute keywords.
-
#sentence ⇒ Object
Returns the value of attribute sentence.
Instance Method Summary collapse
-
#initialize(sentence, word_list = "stop_words") ⇒ Keywords
constructor
A new instance of Keywords.
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
#keywords ⇒ Object (readonly)
Returns the value of attribute keywords.
9 10 11 |
# File 'lib/find_keywords.rb', line 9 def keywords @keywords end |
#sentence ⇒ Object
Returns the value of attribute sentence.
8 9 10 |
# File 'lib/find_keywords.rb', line 8 def sentence @sentence end |