Class: Bio::GFFbrowser::Digest::LruCacheHelpers::SeekRecList

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

Overview

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

Instance Method Summary collapse

Methods included from LruRec

#fetch

Constructor Details

#initialize(fh, parser, lru) ⇒ SeekRecList

Returns a new instance of SeekRecList.



58
59
60
61
62
63
# File 'lib/bio/db/gff/digest/gfflrucache.rb', line 58

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

Instance Method Details

#[](id) ⇒ Object



71
72
73
74
# File 'lib/bio/db/gff/digest/gfflrucache.rb', line 71

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

#[]=(id, rec) ⇒ Object



65
66
67
68
69
# File 'lib/bio/db/gff/digest/gfflrucache.rb', line 65

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

#eachObject



76
77
78
79
80
# File 'lib/bio/db/gff/digest/gfflrucache.rb', line 76

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