Class: SpellCheck::ProofReader

Inherits:
Object
  • Object
show all
Defined in:
lib/spellcheck/proof_reader.rb

Class Method Summary collapse

Class Method Details

.check(content) ⇒ SpellCheck::Report

Returns check result.

Parameters:

  • content (String)

    text data.

Returns:



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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