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.



13
14
15
16
17
18
19
# File 'lib/database/packed.rb', line 13

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)


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

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

#load_info(oid) ⇒ Object



25
26
27
28
# File 'lib/database/packed.rb', line 25

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

#load_raw(oid) ⇒ Object



30
31
32
33
# File 'lib/database/packed.rb', line 30

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