Class: Database::Packed

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/database/packed.rb

Instance Method Summary collapse

Constructor Details

#initialize(pathname) ⇒ Packed

Returns a new instance of Packed.



10
11
12
13
14
15
16
# File 'lib/database/packed.rb', line 10

def initialize(pathname)
  @pack_file = File.open(pathname, File::RDONLY)
  @reader    = Pack::Reader.new(@pack_file)

  @index_file = File.open(pathname.sub_ext(".idx"), File::RDONLY)
  @index      = Pack::Index.new(@index_file)
end

Instance Method Details

#has?(oid) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/database/packed.rb', line 18

def has?(oid)
  @index.oid_offset(oid) != nil
end

#load_info(oid) ⇒ Object



22
23
24
25
# File 'lib/database/packed.rb', line 22

def load_info(oid)
  offset = @index.oid_offset(oid)
  offset ? load_info_at(offset) : nil
end

#load_raw(oid) ⇒ Object



27
28
29
30
# File 'lib/database/packed.rb', line 27

def load_raw(oid)
  offset = @index.oid_offset(oid)
  offset ? load_raw_at(offset) : nil
end