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