Class: IMP3::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/imp3/config.rb

Constant Summary collapse

CONFIG_FILE =
File.join(IMP3::APP_DIR, "config.yml")

Instance Method Summary collapse

Constructor Details

#initializeConfig

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_genresObject



20
21
22
23
# File 'lib/imp3/config.rb', line 20

def ignore_genres
  @data[:ignore_genres] ||= []
  @data[:ignore_genres]
end

#saveObject



30
31
32
# File 'lib/imp3/config.rb', line 30

def save
  File.new(CONFIG_FILE, "w+").write(@data.to_yaml)
end

#strip_wordsObject



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