Class: Cp8Cli::ConfigStore

Inherits:
Object
  • Object
show all
Defined in:
lib/cp8_cli/config_store.rb

Instance Method Summary collapse

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