Class: Cp8Cli::ConfigStore
- Inherits:
-
Object
- Object
- Cp8Cli::ConfigStore
- Defined in:
- lib/cp8_cli/config_store.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(path) ⇒ ConfigStore
constructor
A new instance of ConfigStore.
- #save(key, value) ⇒ Object
Constructor Details
#initialize(path) ⇒ ConfigStore
Returns a new instance of ConfigStore.
3 4 5 |
# File 'lib/cp8_cli/config_store.rb', line 3 def initialize(path) @path = path end |
Instance Method Details
#[](key) ⇒ Object
7 8 9 |
# File 'lib/cp8_cli/config_store.rb', line 7 def [](key) data[key] end |
#save(key, value) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/cp8_cli/config_store.rb', line 11 def save(key, value) data[key] = value File.new(path, "w") unless File.exists?(path) File.open(path, "w") { |f| f.write(data.to_yaml) } value end |