Class: Jruby::Mapdb::DB
- Inherits:
-
Object
- Object
- Jruby::Mapdb::DB
- Defined in:
- lib/jruby/mapdb.rb
Instance Attribute Summary collapse
-
#mapdb ⇒ Object
readonly
Returns the value of attribute mapdb.
-
#trees ⇒ Object
readonly
Returns the value of attribute trees.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(dbname = nil) ⇒ DB
constructor
A new instance of DB.
- #tree(treename) ⇒ Object
Constructor Details
#initialize(dbname = nil) ⇒ DB
Returns a new instance of DB.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/jruby/mapdb.rb', line 41 def initialize(dbname=nil) if dbname.nil? @type = :MemoryDB @trees = [] @mapdb = Java::OrgMapdb::DBMaker. newMemoryDB(). closeOnJvmShutdown(). make() else @type = :FileDB @trees = [] @mapdb = Java::OrgMapdb::DBMaker. newFileDB(Java::JavaIo::File.new("#{dbname}")). closeOnJvmShutdown(). writeAheadLogDisable(). make() end end |
Instance Attribute Details
#mapdb ⇒ Object (readonly)
Returns the value of attribute mapdb.
40 41 42 |
# File 'lib/jruby/mapdb.rb', line 40 def mapdb @mapdb end |
#trees ⇒ Object (readonly)
Returns the value of attribute trees.
40 41 42 |
# File 'lib/jruby/mapdb.rb', line 40 def trees @trees end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
40 41 42 |
# File 'lib/jruby/mapdb.rb', line 40 def type @type end |
Instance Method Details
#tree(treename) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/jruby/mapdb.rb', line 59 def tree(treename) raise "Tree already defined" if @trees.include?(treename) || Object.const_defined?(treename) trees << treename Object.const_set treename, Class.new(Tree) Object.const_get(treename).instance_variable_set :@mapdb, @mapdb Object.const_get(treename).instance_variable_set :@tree, @mapdb.getTreeMap("#{treename}") end |