Class: Linter::MisusedWords

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

Class Method Summary collapse

Class Method Details

.analyze(text) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/linter/misused_words.rb', line 5

def self.analyze(text)
  result = OpenStruct.new(
    misused_words: [],
    trend: ''
  )
  wordlists.dig('problematic').each do |problematic_word|
    word = problematic_word['word']
    regex = /\b#{word}\b/i
    result.misused_words << problematic_word if text.scan(regex).any?
  end
  result
end