Class: BioLocus::SerializeMapper
- Inherits:
-
Object
- Object
- BioLocus::SerializeMapper
- Defined in:
- lib/bio-locus/dbmapper.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #close ⇒ Object
-
#initialize(dbname) ⇒ SerializeMapper
constructor
A new instance of SerializeMapper.
Constructor Details
#initialize(dbname) ⇒ SerializeMapper
Returns a new instance of SerializeMapper.
4 5 6 7 8 9 10 |
# File 'lib/bio-locus/dbmapper.rb', line 4 def initialize dbname @dbname = dbname @h = {} if File.exist?(@dbname) @h = Marshal.load(File.read(@dbname)) end end |
Instance Method Details
#[](key) ⇒ Object
12 13 14 |
# File 'lib/bio-locus/dbmapper.rb', line 12 def [] key @h[key] end |
#[]=(key, value) ⇒ Object
16 17 18 |
# File 'lib/bio-locus/dbmapper.rb', line 16 def []= key, value @h[key] = value end |
#close ⇒ Object
20 21 22 |
# File 'lib/bio-locus/dbmapper.rb', line 20 def close File.open(@dbname, 'w') {|f| f.write(Marshal.dump(@h)) } end |