module Lyp::Settings
Public Class Methods
[](path)
click to toggle source
# File lib/lyp/settings.rb, line 13 def [](path) h = load while path =~ /^([^\/]+)\/(.+)$/ h = h[$1.to_sym] ||= {} path = $2 end h[path.to_sym] end
[]=(path, value)
click to toggle source
# File lib/lyp/settings.rb, line 23 def []=(path, value) h = load while path =~ /^([^\/]+)\/(.+)$/ h = h[$1.to_sym] ||= {} path = $2 end h[path.to_sym] = value save value end
get_value(path, default = nil)
click to toggle source
# File lib/lyp/settings.rb, line 35 def get_value(path, default = nil) req_ext 'yaml' v = self[path] v ? YAML.load(v) : default end
load()
click to toggle source
# File lib/lyp/settings.rb, line 3 def load req_ext 'yaml' @settings = YAML.load(IO.read(Lyp.settings_file)) rescue {} end
save()
click to toggle source
# File lib/lyp/settings.rb, line 8 def save req_ext 'yaml' File.open(Lyp.settings_file, 'w+') {|f| f << YAML.dump(@settings)} end
set_value(path, value)
click to toggle source
# File lib/lyp/settings.rb, line 41 def set_value(path, value) req_ext 'yaml' self[path] = YAML.dump(value) end