Class: AbsoluteRenamer::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/absolute_renamer/config.rb

Overview

Class handeling the configuration.

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object

Returns a configuration value identified by key.



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

def [](key)
    @conf[key]
end

.[]=(key, value) ⇒ Object

Sets a configuration value in the @conf variable.



35
36
37
# File 'lib/absolute_renamer/config.rb', line 35

def []=(key, value)
    @conf[key] = value
end

.get(key = nil) ⇒ Object

Returns a configuration value identified by key. If key is ignored, returns the @conf hash.



19
20
21
22
# File 'lib/absolute_renamer/config.rb', line 19

def get(key = nil)
    return @conf[key] if @conf.has_key?(key)
    return @conf
end

.load(config_path) ⇒ Object

Open and load a Yaml file into the @conf variable. config_path: path of the file to load.



9
10
11
12
13
14
15
# File 'lib/absolute_renamer/config.rb', line 9

def load(config_path)
    @conf = YAML::load_file(config_path)

    @conf[:options] ||= {}
    @conf[:options][:format] ||= '$'
    @conf[:options][:ext_format] ||= '$'
end

.set(key, value = '') ⇒ Object

Sets a configuration value in the @conf variable.



25
26
27
# File 'lib/absolute_renamer/config.rb', line 25

def set(key, value = '')
    @conf[key] = value
end