Class: GameMachine::DataStores::Mapdb

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/game_machine/data_stores/mapdb.rb

Instance Method Summary collapse

Instance Method Details

#connectObject



36
37
38
39
40
41
42
43
44
# File 'lib/game_machine/data_stores/mapdb.rb', line 36

def connect
  unless @client
    @db = DataStores::DBMaker.newFileDB(java.io.File.new(dbfile)).
      closeOnJvmShutdown.
      make
    @client = @db.getTreeMap("entities")
  end
  @client
end

#dbfileObject



32
33
34
# File 'lib/game_machine/data_stores/mapdb.rb', line 32

def dbfile
  File.join(GameMachine.app_root,'db','mapdb.db')
end

#dump(path, format = :yaml) ⇒ Object

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/game_machine/data_stores/mapdb.rb', line 19

def dump(path,format=:yaml)
  raise NotImplementedError
end

#keysObject



15
16
17
# File 'lib/game_machine/data_stores/mapdb.rb', line 15

def keys
  @client.keys
end

#load(path, format = :yaml) ⇒ Object

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/game_machine/data_stores/mapdb.rb', line 23

def load(path,format=:yaml)
  raise NotImplementedError
end

#set(key, value) ⇒ Object



27
28
29
30
# File 'lib/game_machine/data_stores/mapdb.rb', line 27

def set(key,value)
  @client.put(key,value)
  @db.commit
end

#shutdownObject



11
12
13
# File 'lib/game_machine/data_stores/mapdb.rb', line 11

def shutdown
  @client.close
end