Class: Vimdb::DB

Inherits:
Object
  • Object
show all
Defined in:
lib/vimdb/db.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (DB) initialize(file = ENV['VIMDB_DB'] || Dir.home + '/.vimdb.pstore')

Returns a new instance of DB



6
7
8
9
# File 'lib/vimdb/db.rb', line 6

def initialize(file = ENV['VIMDB_DB'] || Dir.home + '/.vimdb.pstore')
  @file = file
  @db = PStore.new(@file)
end

Instance Attribute Details

- (Object) file

Returns the value of attribute file



5
6
7
# File 'lib/vimdb/db.rb', line 5

def file
  @file
end

Instance Method Details

- (Object) get(key)



11
12
13
# File 'lib/vimdb/db.rb', line 11

def get(key)
  @db.transaction(true) { @db[key] }
end

- (Object) set(key, value)



15
16
17
# File 'lib/vimdb/db.rb', line 15

def set(key, value)
  @db.transaction { @db[key] = value }
end