Class: Rufus::Tokyo::Dystopia::Words

Inherits:
Object
  • Object
show all
Defined in:
lib/rufus/tokyo/dystopia/words.rb

Overview

Tokyo Dystopia words database.

tokyocabinet.sourceforge.net/dystopiadoc/

Instance Method Summary collapse

Constructor Details

#initialize(path, opts = {}) ⇒ Words

Opens/create a Tokyo Dystopia words database.


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rufus/tokyo/dystopia/words.rb', line 42

def initialize (path, opts={})

  # tcwdb.h :
  #
  #   enum {                 /* enumeration for open modes */
  #     WDBOREADER = 1 << 0, /* open as a reader */
  #     WDBOWRITER = 1 << 1, /* open as a writer */
  #     WDBOCREAT = 1 << 2,  /* writer creating */
  #     WDBOTRUNC = 1 << 3,  /* writer truncating */
  #     WDBONOLCK = 1 << 4,  /* open without locking */
  #     WDBOLCKNB = 1 << 5   /* lock without blocking */
  #   };

  mode = 0

  @db = dlib.tcwdbnew

  dlib.tcwdbopen(@db, path, mode) || raise_error
end