Class: PHash
- Inherits:
-
Hash
- Object
- Hash
- PHash
- Defined in:
- lib/phash.rb
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize(path) ⇒ PHash
constructor
A new instance of PHash.
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
#flush ⇒ Object
13 14 15 |
# File 'lib/phash.rb', line 13 def flush File.open(@path,'w') { |f| f.write(self.to_yaml)} end |