Class: LevelDB::DB

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/leveldb.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pathnameObject (readonly)

Returns the value of attribute pathname.



33
34
35
# File 'lib/leveldb.rb', line 33

def pathname
  @pathname
end

Class Method Details

.create(pathname) ⇒ Object

Creates a new LevelDB database stored on disk at pathname. Throws an exception if the database already exists.



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

def create pathname
  make path_string(pathname), true, true
end

.load(pathname) ⇒ Object

Loads a LevelDB database stored on disk at pathname. Throws an exception unless the database already exists.



21
22
23
# File 'lib/leveldb.rb', line 21

def load pathname
  make path_string(pathname), false, false
end

.new(pathname) ⇒ Object

Loads or creates a LevelDB database as necessary, stored on disk at pathname.



9
10
11
# File 'lib/leveldb.rb', line 9

def new pathname
  make path_string(pathname), true, false
end

Instance Method Details

#each(*args, &block) ⇒ Object



41
42
43
44
45
# File 'lib/leveldb.rb', line 41

def each(*args, &block)
  i = iterator(*args)
  i.each(&block) if block
  i
end

#inspectObject



51
52
53
# File 'lib/leveldb.rb', line 51

def inspect
  %(<#{self.class} #{@pathname.inspect}>)
end

#iterator(*args) ⇒ Object



47
# File 'lib/leveldb.rb', line 47

def iterator(*args); Iterator.new self, *args end

#keysObject



48
# File 'lib/leveldb.rb', line 48

def keys; map { |k, v| k } end

#valuesObject



49
# File 'lib/leveldb.rb', line 49

def values; map { |k, v| v } end