Class: FlexConfig
- Inherits:
-
Object
- Object
- FlexConfig
- Defined in:
- lib/flex_config.rb
Instance Method Summary collapse
- #get_config(path) ⇒ Object
-
#initialize(path, configs) ⇒ FlexConfig
constructor
A new instance of FlexConfig.
Constructor Details
#initialize(path, configs) ⇒ FlexConfig
Returns a new instance of FlexConfig.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/flex_config.rb', line 4 def initialize (path, configs) unless Dir.exist?(path) Dir.mkdir(path) end file_path = path + '/config.yml' if File.exist?(file_path) config = YAML::load(File.open(file_path, 'r')) else config = {} end config.merge!(configs) output = File.open(file_path, 'w') output.puts config.to_yaml output.close end |
Instance Method Details
#get_config(path) ⇒ Object
26 27 28 29 30 |
# File 'lib/flex_config.rb', line 26 def get_config (path) file_path = path + '/config.yml' YAML::load(File.open(file_path, 'r')) end |