class Bio::FlatFileIndex::BDBwrapper

Public Class Methods

new(name, filename, *arg) click to toggle source
   # File lib/bio/io/flatfile/bdb.rb
44 def initialize(name, filename, *arg)
45   @dbname = name
46   @file = nil
47   @filename = filename
48   #self.open(*arg)
49 end

Public Instance Methods

[](arg) click to toggle source
   # File lib/bio/io/flatfile/bdb.rb
73 def [](arg)
74   #self.open
75   if @file then
76     @file[arg]
77   else
78     nil
79   end
80 end
[]=(key, val) click to toggle source
   # File lib/bio/io/flatfile/bdb.rb
82 def []=(key, val)
83   #self.open
84   @file[key.to_s] = val.to_s
85 end
close() click to toggle source
   # File lib/bio/io/flatfile/bdb.rb
64 def close
65   if @file
66     DEBUG.print "BDBwrapper: close #{filename}\n"
67     @file.close
68     @file = nil
69   end
70   nil
71 end
filename() click to toggle source
   # File lib/bio/io/flatfile/bdb.rb
51 def filename
52   File.join(@dbname, @filename)
53 end
keys() click to toggle source
    # File lib/bio/io/flatfile/bdb.rb
 95 def keys
 96   if @file then
 97     @file.keys
 98   else
 99     []
100   end
101 end
open(flag = BDBdefault.flag_read, permission = BDBdefault.permission) click to toggle source
   # File lib/bio/io/flatfile/bdb.rb
55 def open(flag = BDBdefault.flag_read,
56          permission = BDBdefault.permission)
57   unless @file then
58     DEBUG.print "BDBwrapper: open #{filename}\n"
59     @file = BDB::Btree.open(filename, nil, flag, permission)
60   end
61   true
62 end
writeback_array(prefix, array, *arg) click to toggle source
   # File lib/bio/io/flatfile/bdb.rb
87 def writeback_array(prefix, array, *arg)
88   self.close
89   self.open(*arg)
90   array.each_with_index do |val, key|
91     @file["#{prefix}#{key}"] = val.to_s
92   end
93 end