Class: FindKeywords::RemoveWordsList

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

Constant Summary collapse

@@instance_collector =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(word_list) ⇒ RemoveWordsList

Returns a new instance of RemoveWordsList.



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/find_keywords/remove_words_list.rb', line 47

def initialize (word_list)
  if word_list.is_a?(String)
    @word_list = word_list.split(" ")
  elsif word_list.is_a?(Array)
    @word_list = word_list
  elsif word_list.is_a?(Hash)
    @word_list = word_list.collect { |k, v| "#{k} #{v} " }.join.split(" ")
  else
    @word_list = []
  end
  @@instance_collector << self
end

Instance Attribute Details

#word_listObject (readonly)

Returns the value of attribute word_list.



43
44
45
# File 'lib/find_keywords/remove_words_list.rb', line 43

def word_list
  @word_list
end

Class Method Details

.allObject



60
61
62
# File 'lib/find_keywords/remove_words_list.rb', line 60

def self.all
  all_custom + stop_words
end

.all_customObject



64
65
66
67
68
69
70
71
72
# File 'lib/find_keywords/remove_words_list.rb', line 64

def self.all_custom
  all_words = []
  @@instance_collector.each do | words |
    words.word_list.each do | word |
      all_words << word
    end
  end
  all_words
end

.stop_wordsObject



74
75
76
# File 'lib/find_keywords/remove_words_list.rb', line 74

def self.stop_words
  STOP_WORDS
end