update doc.
[chise/ruby.git] / src / chise / rbchise.rb
1 #!/usr/bin/env ruby
2 # 'rbchise.so' ext compatible library by eto 2003-0317
3 # $Id: rbchise.rb,v 1.1 2003-11-10 08:11:47 eto Exp $
4 # Copyright (C) 2002-2003 Kouichirou Eto, All rights reserved.
5 # This is free software with ABSOLUTELY NO WARRANTY.
6 # You can redistribute it and/or modify it under the terms of the GNU GPL2.
7
8 require 'bdb'
9
10 module CHISE
11
12   class DataSource #======================================================================
13     NONE = 0
14     Berkeley_DB = 1
15     #DEFAULT_CHAR_DB_DIR = "/usr/local/lib/chise/char-db"
16     DEFAULT_CHAR_DB_DIR = "d:/work/chise/char-db"
17     def initialize(type=Berkeley_DB, location = DEFAULT_CHAR_DB_DIR)
18       @type, @location = type, location
19     end
20     def close
21     end
22     def open_decofing_table(ccs)
23       DecodingTable.new(self, ccs)
24     end
25     def open_feature_table(feature)
26       FeatureTable.new(self, feature)
27     end
28   end
29
30   class AttributeTable #======================================================================
31     def open(from, to, real_subtpe, accessmask, modemask)
32     end
33     def get_value(char_id)
34       @db.get(char_id)
35     end
36     def close
37     end
38   end
39   
40   class DecodingTable #======================================================================
41     def initialize(ds, ccs)
42       @ds, @ccs = ds, ccs
43       #\82±\82±\82Åopen\82·\82é
44       @db = nil
45     end
46     def get_char(code_point)
47       @db.get(code_point)
48     end
49     def close
50     end
51   end
52   
53   class FeatureTable #======================================================================
54     def initialize(ds, feature)
55       @ds, @feature = ds, feature
56       #\82±\82±\82Åopen\82·\82é
57       @db = nil
58     end
59     def get_value(char_id)
60       @db.get(char_id)
61     end
62     def close
63     end
64   end
65   
66   class Value #======================================================================
67     def initialize(v)
68       @v = v;
69     end
70     def to_s()      @v;    end
71   end
72   
73 end
74
75 #----------------------------------------------------------------------end.