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, parser) ⇒ SeekRecList

Returns a new instance of SeekRecList.



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

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

Instance Method Details

#[](id) ⇒ Object



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

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

#[]=(id, rec) ⇒ Object



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

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

#eachObject



55
56
57
58
59
# File 'lib/bio/db/gff/digest/gffnocache.rb', line 55

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