Class: BioLocus::SerializeMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/bio-locus/dbmapper.rb

Instance Method Summary collapse

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

#closeObject



20
21
22
# File 'lib/bio-locus/dbmapper.rb', line 20

def close
  File.open(@dbname, 'w') {|f| f.write(Marshal.dump(@h)) }
end