Class: Gemfilelint::SpellChecker
- Inherits:
-
Object
- Object
- Gemfilelint::SpellChecker
- Defined in:
- lib/gemfilelint.rb
Instance Attribute Summary collapse
-
#detector ⇒ Object
readonly
Returns the value of attribute detector.
-
#haystack ⇒ Object
readonly
Returns the value of attribute haystack.
Instance Method Summary collapse
- #correct(needle) ⇒ Object
-
#initialize(haystack) ⇒ SpellChecker
constructor
A new instance of SpellChecker.
Constructor Details
#initialize(haystack) ⇒ SpellChecker
Returns a new instance of SpellChecker.
13 14 15 16 |
# File 'lib/gemfilelint.rb', line 13 def initialize(haystack) @detector = SimilarityDetector.new(haystack) @haystack = haystack end |
Instance Attribute Details
#detector ⇒ Object (readonly)
Returns the value of attribute detector.
11 12 13 |
# File 'lib/gemfilelint.rb', line 11 def detector @detector end |
#haystack ⇒ Object (readonly)
Returns the value of attribute haystack.
11 12 13 |
# File 'lib/gemfilelint.rb', line 11 def haystack @haystack end |
Instance Method Details
#correct(needle) ⇒ Object
18 19 20 21 22 |
# File 'lib/gemfilelint.rb', line 18 def correct(needle) return [] if haystack.include?(needle) detector.similar_words(needle, 2) end |