Class: PHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/phash.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PHash

Returns a new instance of PHash.



5
6
7
8
9
10
11
# File 'lib/phash.rb', line 5

def initialize(path)
  @path = path
  if File.exist?(@path)
    data = YAML.load(File.read(@path)) rescue nil
    self.replace(data) if data
  end
end

Instance Method Details

#flushObject



13
14
15
# File 'lib/phash.rb', line 13

def flush
  File.open(@path,'w') { |f| f.write(self.to_yaml)}
end