class Nin::YamlStore
Constants
- DEFAULT_FILE
Attributes
file[R]
Public Class Methods
new(file = DEFAULT_FILE)
click to toggle source
# File lib/nin/yaml_store.rb, line 7 def initialize(file = DEFAULT_FILE) @file = file init_store end
Public Instance Methods
read()
click to toggle source
# File lib/nin/yaml_store.rb, line 13 def read Psych.load_file(@file) || {} # Psych returns false if the file is empty end
write(hash)
click to toggle source
# File lib/nin/yaml_store.rb, line 17 def write(hash) File.open(@file, 'w') do |file| file.write(Psych.dump(hash)) end end
Private Instance Methods
init_store()
click to toggle source
# File lib/nin/yaml_store.rb, line 25 def init_store return if File.exist?(@file) File.open(@file, "w") end