Module: Twterm::Config
- Defined in:
- lib/twterm/config.rb
Constant Summary collapse
- CONFIG_FILE =
"#{ENV['HOME']}/.twterm.yml"
Class Method Summary collapse
Class Method Details
.[](key) ⇒ Object
5 6 7 |
# File 'lib/twterm/config.rb', line 5 def [](key) @config[key] end |
.[]=(key, value) ⇒ Object
9 10 11 12 |
# File 'lib/twterm/config.rb', line 9 def []=(key, value) @config[key] = value save end |
.load ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/twterm/config.rb', line 14 def load unless File.exist? CONFIG_FILE @config = {} return end @config = YAML.load(File.read(CONFIG_FILE)) || {} end |
.save ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/twterm/config.rb', line 24 def save begin file = File.open(CONFIG_FILE, 'w', 0600) file.write @config.to_yaml rescue puts 'exception raised' ensure file.close end end |