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.
5 6 7 |
# File 'lib/cp8_cli/config_store.rb', line 5 def initialize(path) @path = path end |
Instance Method Details
#[](key) ⇒ Object
9 10 11 |
# File 'lib/cp8_cli/config_store.rb', line 9 def [](key) data[key] end |
#save(key, value) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/cp8_cli/config_store.rb', line 13 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 |