Class: Bio::GFFbrowser::Digest::LruCacheHelpers::SeekRecList
- Inherits:
-
Object
- Object
- Bio::GFFbrowser::Digest::LruCacheHelpers::SeekRecList
- 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
- #[](id) ⇒ Object
- #[]=(id, rec) ⇒ Object
- #each ⇒ Object
-
#initialize(fh, parser, lru) ⇒ SeekRecList
constructor
A new instance of SeekRecList.
Methods included from LruRec
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 |
#each ⇒ Object
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 |