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(lang) ⇒ HTML_Spellchecker

Returns a new instance of HTML_Spellchecker.



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

def initialize(lang)
  @dict = FFI::Hunspell.dict(lang)
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 'en_US'
end

.frenchObject



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

def self.french
  @french ||= self.new 'fr_FR'
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