Class: IMP3::Config
Constant Summary collapse
Instance Method Summary collapse
- #ignore_genres ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #save ⇒ Object
- #strip_words ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/imp3/config.rb', line 8 def initialize @data = {} if File.exist?(CONFIG_FILE) begin @data = YAML.load_file(CONFIG_FILE) rescue raise "Unable to read config file #{CONFIG_FILE}" end end end |
Instance Method Details
#ignore_genres ⇒ Object
20 21 22 23 |
# File 'lib/imp3/config.rb', line 20 def ignore_genres @data[:ignore_genres] ||= [] @data[:ignore_genres] end |
#save ⇒ Object
30 31 32 |
# File 'lib/imp3/config.rb', line 30 def save File.new(CONFIG_FILE, "w+").write(@data.to_yaml) end |
#strip_words ⇒ Object
25 26 27 28 |
# File 'lib/imp3/config.rb', line 25 def strip_words @data[:strip_words] ||= %w(the a of in) @data[:strip_words] end |