Class: Tagmv::Config
- Inherits:
-
Object
- Object
- Tagmv::Config
- Defined in:
- lib/tagmv/config.rb
Instance Method Summary collapse
- #defaults ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #load ⇒ Object
- #save(config) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
5 6 7 |
# File 'lib/tagmv/config.rb', line 5 def initialize( = {}) @path = [:path] || File.("~/.tagmv.yml") end |
Instance Method Details
#defaults ⇒ Object
9 10 11 |
# File 'lib/tagmv/config.rb', line 9 def defaults {top_level_tags: ["blog", "media"]} end |
#load ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/tagmv/config.rb', line 13 def load if File.file?(@path) YAML.load(File.open(@path).read) else config = defaults save(config) config end end |
#save(config) ⇒ Object
23 24 25 |
# File 'lib/tagmv/config.rb', line 23 def save(config) File.open(@path, 'w') { |f| f.write(config.to_yaml) } end |