Class: AlfonsoX::SpellChecker::Word

Inherits:
Object
  • Object
show all
Defined in:
lib/alfonsox/spellchecker/word.rb

Overview

Each of the spell-checked words

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(word, line, dictionaries) ⇒ Word

Initialize a spell-checked word.

Parameters:



15
16
17
18
19
20
# File 'lib/alfonsox/spellchecker/word.rb', line 15

def initialize(word, line, dictionaries)
  @word = word
  @line = line
  @dictionaries = dictionaries
  @right = nil
end

Instance Attribute Details

#lineObject (readonly)

Returns the value of attribute line.



8
9
10
# File 'lib/alfonsox/spellchecker/word.rb', line 8

def line
  @line
end

#wordObject (readonly)

Returns the value of attribute word.



8
9
10
# File 'lib/alfonsox/spellchecker/word.rb', line 8

def word
  @word
end

Instance Method Details

#checkBoolean

Check if the word is right. Assigns the Word#right attribute.

Returns:

  • (Boolean)

    true if the word is rightfully written, false otherwise.



25
26
27
28
29
30
31
# 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