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