Class: Bio::GFFbrowser::Digest::NoCacheHelpers::SeekRecList

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/db/gff/digest/gffnocache.rb

Overview

Helper class which gives Hash-like access to the no-cache GFF3 file

Instance Method Summary collapse

Constructor Details

#initialize(fh) ⇒ SeekRecList

Returns a new instance of SeekRecList.



34
35
36
37
# File 'lib/bio/db/gff/digest/gffnocache.rb', line 34

def initialize fh
  @fh = fh
  @h = {}
end

Instance Method Details

#[](id) ⇒ Object



45
46
47
48
# File 'lib/bio/db/gff/digest/gffnocache.rb', line 45

def [](id)
  fpos = @h[id]
  SeekRec::fetch(@fh,fpos)
end

#[]=(id, rec) ⇒ Object



39
40
41
42
43
# File 'lib/bio/db/gff/digest/gffnocache.rb', line 39

def []= id, rec
  raise "id #{id} occurs twice!" if @h[id]
  fpos = rec.io_seek
  @h[id] = fpos
end

#eachObject



50
51
52
53
54
# File 'lib/bio/db/gff/digest/gffnocache.rb', line 50

def each 
  @h.each do | id,fpos |
    yield id, self[id]
  end
end