Class: Lunar::Words
- Inherits:
-
Array
- Object
- Array
- Lunar::Words
- Defined in:
- lib/lunar/words.rb
Overview
i.e. Words.new(“the quick brown”) == %w(the quick brown)
Constant Summary collapse
- SEPARATOR =
/\s+/
Instance Method Summary collapse
-
#initialize(str, stopwords = true) ⇒ Words
constructor
A new instance of Words.
Constructor Details
#initialize(str, stopwords = true) ⇒ Words
Returns a new instance of Words.
9 10 11 12 13 14 15 16 17 |
# File 'lib/lunar/words.rb', line 9 def initialize(str, stopwords = true) words = str.split(SEPARATOR). reject { |w| w.to_s.strip.empty? }. map { |w| sanitize(w) } words.reject! { |w| Stopwords.include?(w) } if stopwords super(words) end |