Class: Hunspell

Inherits:
Object
  • Object
show all
Defined in:
lib/hunspell-ffi.rb

Defined Under Namespace

Modules: C

Instance Method Summary collapse

Constructor Details

#initialize(affpath, dicpath) ⇒ Hunspell

TODO RDoc



14
15
16
# File 'lib/hunspell-ffi.rb', line 14

def initialize(affpath, dicpath)
  @handler = C.Hunspell_create(affpath, dicpath)
end

Instance Method Details

#spell(word) ⇒ Object Also known as: check



18
19
20
# File 'lib/hunspell-ffi.rb', line 18

def spell(word)
  C.Hunspell_spell(@handler, word)
end

#suggest(word) ⇒ Object



23
24
25
26
27
28
# File 'lib/hunspell-ffi.rb', line 23

def suggest(word)
  ptr = FFI::MemoryPointer.new(:pointer, 1)    
  len = Hunspell::C.Hunspell_suggest(@handler, ptr, word)
  str_ptr = ptr.read_pointer
  str_ptr.null? ? [] : str_ptr.get_array_of_string(0, len).compact
end