update.
[chise/ruby.git] / ext / sample.rb
index 9702556..56c4ada 100755 (executable)
@@ -1,7 +1,13 @@
 #!/usr/bin/env ruby
 # Copyright (C) 2002-2004 Kouichirou Eto, All rights reserved.
 
-require "libchise_c"
+require "libchise_c.so"
+module CHISE
+  DataSource = DataSource_C
+  Feature = Feature_C
+  CCS = CCS_C
+end
+
 $LOAD_PATH.unshift("..")
 require "chise/qp"
 
@@ -12,7 +18,7 @@ def die(msg)
 end
 
 def main
-  db_dir = CHISE::DB_DIR
+  db_dir = CHISE::DataSource::DB_DIR
   @ds = CHISE::DataSource.new(CHISE::DataSource::Berkeley_DB, db_dir, 0, 0755)
   die "Can't open data source" if @ds.nil?
 
@@ -28,10 +34,10 @@ def main
 
   ft = @ds.get_feature("ideographic-structure")
   value = ft.get_value(char_id)
-  printf("#x%X => %s\n", char_id, value.to_s)
+  printf("#x%X => %s\n", char_id, value)
 
   @ds.each_feature_name {|name|
-    #puts "rb_feature : "+name
+    puts "feature : "+name
   }
 
   ft = @ds.get_feature("numeric-value")
@@ -40,18 +46,18 @@ def main
 
     ucs = @ds.get_feature("=ucs").get_value(cid)
     if ucs
-      printf("[U-%08X]", ucs.to_s.to_i)
+      printf("[U-%08X]", ucs.to_i)
     else
       ucs = @ds.get_feature("=>ucs").get_value(cid)
       if ucs
-       printf("(U-%08X)", ucs.to_s.to_i)
+       printf("(U-%08X)", ucs.to_i)
       else
        printf("            ")
       end
     end
 
     printf(" %s", @ds.get_feature("name").get_value(cid))
-    printf(" %s\n", valdatum.to_s)
+    printf(" %s\n", valdatum)
   }
 
   @ds.close