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.



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