Class: GoldMine::IDB

Inherits:
DB
  • Object
show all
Defined in:
lib/gold_mine/idb.rb

Overview

Database with a related index file.

Instance Attribute Summary collapse

Attributes inherited from DB

#options, #path

Instance Method Summary collapse

Methods inherited from DB

default_options, #fortunes

Constructor Details

#initialize(options = {}) ⇒ IDB

Returns a new instance of IDB.



8
9
10
11
12
13
# File 'lib/gold_mine/idb.rb', line 8

def initialize(options = {})
  super

  @index_reader = IndexReader.new("#{@path}.dat")
  @options = @index_reader.options
end

Instance Attribute Details

#index_readerObject (readonly)

Returns the value of attribute index_reader.



6
7
8
# File 'lib/gold_mine/idb.rb', line 6

def index_reader
  @index_reader
end

Instance Method Details

#randomObject



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

def random
  find_fortune(@index_reader.random_pointer)
end