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

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#pathnameObject (readonly)

Returns the value of attribute pathname.



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

def pathname
  @pathname
end

Class Method Details

.create(pathname, options = {}) ⇒ Object

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

See #make for possible options.



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

def create pathname, options={}
  make path_string(pathname),
       options.merge(:create_if_missing => true,
                     :error_if_exists => true)
end

.load(pathname) ⇒ Object

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



29
30
31
32
# File 'lib/leveldb.rb', line 29

def load pathname
  make path_string(pathname),
       { :create_if_missing => false, :error_if_exists => false }
end

.new(pathname, options = {}) ⇒ Object

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

See #make for possible options.



11
12
13
14
15
# File 'lib/leveldb.rb', line 11

def new pathname, options={}
  make path_string(pathname),
       options.merge(:create_if_missing => true,
                     :error_if_exists => false)
end

Instance Method Details

#each(*args, &block) ⇒ Object



52
53
54
55
56
# File 'lib/leveldb.rb', line 52

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

#inspectObject



62
63
64
# File 'lib/leveldb.rb', line 62

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

#iterator(*args) ⇒ Object



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

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

#keysObject



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

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

#valuesObject



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

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