Class: Gel::Config
- Inherits:
-
Object
- Object
- Gel::Config
- Defined in:
- lib/gel/config.rb
Instance Method Summary collapse
- #[](group = nil, key) ⇒ Object
- #[]=(group = nil, key, value) ⇒ Object
- #config ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
4 5 6 7 8 |
# File 'lib/gel/config.rb', line 4 def initialize @root = File.("~/.config/gel") @path = File.join(@root, "config") @config = nil end |
Instance Method Details
#[](group = nil, key) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/gel/config.rb', line 14 def [](group = nil, key) if group.nil? group, key = key.split(".", 2) end (group ? (config[group.to_s] || {}) : config)[key.to_s] end |
#[]=(group = nil, key, value) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/gel/config.rb', line 22 def []=(group = nil, key, value) if group.nil? group, key = key.split(".", 2) end (group ? (config[group.to_s] ||= {}) : config)[key.to_s] = value.to_s write(config) end |
#config ⇒ Object
10 11 12 |
# File 'lib/gel/config.rb', line 10 def config @config ||= read end |