Class: Lunar::Words

Inherits:
Array
  • Object
show all
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

Constructor Details

#initialize(str) ⇒ Words

Returns a new instance of Words.



9
10
11
12
13
14
15
16
# File 'lib/lunar/words.rb', line 9

def initialize(str)
  words = str.split(SEPARATOR).
    reject { |w| w.to_s.strip.empty? }.
    map    { |w| sanitize(w) }.
    reject { |w| Stopwords.include?(w) }

  super(words)
end