class AlfonsoX::SpellChecker::Word
Each of the spell-checked words
Attributes
line[R]
word[R]
Public Class Methods
new(word, line, dictionaries)
click to toggle source
Initialize a spell-checked word. @param [String] word Word
to be spell-checked. @param [Integer] line Line number this word belongs to. @param [Array<AlfonsoX::SpellChecker::Dictionary::Hunspell, AlfonsoX::SpellChecker::Dictionary::Rubymine>]
dictionaries Array of dictionaries that will be used to check if this word spelling is right.
# File lib/alfonsox/spellchecker/word.rb, line 15 def initialize(word, line, dictionaries) @word = word @line = line @dictionaries = dictionaries @right = nil end
Public Instance Methods
check()
click to toggle source
Check if the word is right. Assigns the Word#right attribute. @return [Boolean] true if the word is rightfully written, false otherwise.
# File lib/alfonsox/spellchecker/word.rb, line 25 def check @dictionaries.each do |dictionary| @right = check_for_dictionary(dictionary) return true if @right end false end
Private Instance Methods
check_for_dictionary(dictionary)
click to toggle source
Check if the word is rightfully written for a dictionary. @param [Array<AlfonsoX::SpellChecker::Dictionary::Hunspell, AlfonsoX::SpellChecker::Dictionary::Rubymine>]
dictionaries Array of dictionaries that will be used to check if this word spelling is right.
@return [Boolean] true if the word is rightfully written for the passed dictionary, false otherwise.
# File lib/alfonsox/spellchecker/word.rb, line 39 def check_for_dictionary(dictionary) right = dictionary.word_present?(@word) return true if right false end