Class: Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/propre/settings.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Settings

Returns a new instance of Settings.



6
7
8
9
10
11
# File 'lib/propre/settings.rb', line 6

def initialize(path)
  @path = path
  if !File.exist?(path) then FileUtils.touch(path) end
  conf = YAML.load_file(path)
  @settings = conf ? conf : Hash.new
end

Instance Method Details

#get(key) ⇒ Object



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

def get(key)
  @settings[key]
end

#set(key, value) ⇒ Object



17
18
19
20
# File 'lib/propre/settings.rb', line 17

def set(key, value)
  @settings[key] = value
  File.open(@path, 'w') { |f| YAML.dump(@settings, f) }
end