Class: HTML_Spellchecker

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

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aff, dic) ⇒ HTML_Spellchecker

Returns a new instance of HTML_Spellchecker.



17
18
19
# File 'lib/html_spellchecker.rb', line 17

def initialize(aff, dic)
  @dict = Hunspell.new(aff, dic)
end

Class Attribute Details

.spellcheckable_tagsObject

Returns the value of attribute spellcheckable_tags.



26
27
28
# File 'lib/html_spellchecker.rb', line 26

def spellcheckable_tags
  @spellcheckable_tags
end

Class Method Details

.englishObject



9
10
11
# File 'lib/html_spellchecker.rb', line 9

def self.english
  @english ||= self.new("/usr/share/hunspell/en_US.aff", "/usr/share/hunspell/en_US.dic")
end

.frenchObject



13
14
15
# File 'lib/html_spellchecker.rb', line 13

def self.french
  @french ||= self.new("/usr/share/hunspell/fr_FR.aff", "/usr/share/hunspell/fr_FR.dic")
end

Instance Method Details

#spellcheck(html) ⇒ Object



21
22
23
# File 'lib/html_spellchecker.rb', line 21

def spellcheck(html)
  Nokogiri::HTML::DocumentFragment.parse(html).spellcheck(@dict)
end