Class: Config
- Inherits:
-
Object
- Object
- Config
- Defined in:
- lib/vpsmatrix/config.rb
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#write(key, value) ⇒ Object
how to write with nested keys.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/vpsmatrix/config.rb', line 5 def initialize @file_path = ".vps_matrix/config.yml" unless File.exists? @file_path Dir.mkdir ".vps_matrix" File.open(@file_path, 'w') do |file| file.write "comment: 'Config file for VPS Matrix services'" end end @content = YAML::load_file(@file_path) end |
Instance Method Details
#content ⇒ Object
16 17 18 |
# File 'lib/vpsmatrix/config.rb', line 16 def content @content end |
#write(key, value) ⇒ Object
how to write with nested keys
21 22 23 24 |
# File 'lib/vpsmatrix/config.rb', line 21 def write key, value @content[key] = value File.open(@file_path, 'w') { |f| YAML.dump(@content, f) } end |