Class: Kotoshu::Spellchecker::FluentChecker
- Inherits:
-
Object
- Object
- Kotoshu::Spellchecker::FluentChecker
- Defined in:
- lib/kotoshu/fluent_checker.rb
Overview
Fluent checker for chainable configuration.
Provides a convenient API for spell checking with method chaining.
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
Configuration options.
-
#spellchecker ⇒ Spellchecker
readonly
The underlying spellchecker.
Instance Method Summary collapse
-
#check(text) ⇒ Models::Result::DocumentResult
Check text for spelling errors.
-
#ignore_words(pattern) ⇒ FluentChecker
Ignore words matching pattern.
-
#initialize(spellchecker:, options: {}) ⇒ FluentChecker
constructor
Create a new fluent checker.
-
#max_suggestions(max) ⇒ FluentChecker
Set maximum suggestions.
-
#on_error(&block) ⇒ FluentChecker
Set error callback.
-
#on_progress(&block) ⇒ FluentChecker
Set progress callback.
-
#result ⇒ Models::Result::ResultDocumentResult
Get the result.
Constructor Details
#initialize(spellchecker:, options: {}) ⇒ FluentChecker
Create a new fluent checker.
28 29 30 31 32 33 |
# File 'lib/kotoshu/fluent_checker.rb', line 28 def initialize(spellchecker:, options: {}) @spellchecker = spellchecker @options = @progress_callback = nil @error_callback = nil end |
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns Configuration options.
22 23 24 |
# File 'lib/kotoshu/fluent_checker.rb', line 22 def @options end |
#spellchecker ⇒ Spellchecker (readonly)
Returns The underlying spellchecker.
19 20 21 |
# File 'lib/kotoshu/fluent_checker.rb', line 19 def spellchecker @spellchecker end |
Instance Method Details
#check(text) ⇒ Models::Result::DocumentResult
Check text for spelling errors.
39 40 41 |
# File 'lib/kotoshu/fluent_checker.rb', line 39 def check(text) @spellchecker.check(text) end |
#ignore_words(pattern) ⇒ FluentChecker
Ignore words matching pattern.
50 51 52 53 54 |
# File 'lib/kotoshu/fluent_checker.rb', line 50 def ignore_words(pattern) @options[:ignore_patterns] ||= [] @options[:ignore_patterns] << pattern self end |
#max_suggestions(max) ⇒ FluentChecker
Set maximum suggestions.
60 61 62 63 |
# File 'lib/kotoshu/fluent_checker.rb', line 60 def max_suggestions(max) @options[:max_suggestions] = max self end |
#on_error(&block) ⇒ FluentChecker
Set error callback.
78 79 80 81 |
# File 'lib/kotoshu/fluent_checker.rb', line 78 def on_error(&block) @error_callback = block self end |
#on_progress(&block) ⇒ FluentChecker
Set progress callback.
69 70 71 72 |
# File 'lib/kotoshu/fluent_checker.rb', line 69 def on_progress(&block) @progress_callback = block self end |
#result ⇒ Models::Result::ResultDocumentResult
Get the result.
86 87 88 |
# File 'lib/kotoshu/fluent_checker.rb', line 86 def result check(@text) end |