Class: Huebot::Config
- Inherits:
-
Object
- Object
- Huebot::Config
- Defined in:
- lib/huebot/config.rb
Instance Method Summary collapse
- #[](attr) ⇒ Object
- #[]=(attr, val) ⇒ Object
- #clear ⇒ Object
-
#initialize(path = "~/.config/huebot") ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(path = "~/.config/huebot") ⇒ Config
Returns a new instance of Config.
6 7 8 9 10 11 |
# File 'lib/huebot/config.rb', line 6 def initialize(path = "~/.config/huebot") @path = File.(path) @dir = File.dirname(@path) @dir_exists = File.exist? @dir @config = File.exist?(@path) ? YAML.load_file(@path) : {} end |
Instance Method Details
#[](attr) ⇒ Object
13 14 15 |
# File 'lib/huebot/config.rb', line 13 def [](attr) @config[attr.to_s] end |
#[]=(attr, val) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/huebot/config.rb', line 17 def []=(attr, val) if val.nil? @config.delete(attr.to_s) else @config[attr.to_s] = val end write end |
#clear ⇒ Object
26 27 28 29 |
# File 'lib/huebot/config.rb', line 26 def clear @config.clear write end |