class SpellCheck::ProofReader

Public Class Methods

check(content) click to toggle source

@param [String] content text data. @return [SpellCheck::Report] check result.

# File lib/spellcheck/proof_reader.rb, line 6
def self.check(content)
  report = SpellCheck::Report.new

  content.lines.each.with_index(1) do |line, line_number|

    line.scan(/\w+/).each do |pattern|
      line.chomp!
      result = Filter.spellcheck(pattern)

      next if result[:correct]

      report.errata << Typo.new(
          pattern: pattern,
          expected: result[:expected],
          line: line,
          line_number: line_number
      )
    end
  end

  report
end