Class: XP5K::Config

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

Constant Summary collapse

@@config =

Create a singleton

Hash.new

Class Method Summary collapse

Class Method Details

.[](opt) ⇒ Object

Configuration options getter



27
28
29
# File 'lib/xp5k/config.rb', line 27

def self.[](opt)
  @@config[opt.to_sym]
end

.[]=(opt, value) ⇒ Object

Configuration options setter



32
33
34
# File 'lib/xp5k/config.rb', line 32

def self.[]=(opt, value)
  @@config[opt.to_sym] = value
end

.load(options = {}) ⇒ Object

Load the experiment configuration file



13
14
15
16
17
18
19
20
# File 'lib/xp5k/config.rb', line 13

def self.load(options = {})
  path = options[:path] || 'xp.conf'
  if File.exist?(File.expand_path(File.join(Dir.pwd, path)))
    file_path = File.expand_path(File.join(Dir.pwd, path))
    self.instance_eval(IO.read(file_path),file_path, 1)
    @@config[:loaded] = true
  end
end

.loaded?Boolean

def

self.load

Returns:

  • (Boolean)


22
23
24
# File 'lib/xp5k/config.rb', line 22

def self.loaded?
  @@config[:loaded]
end

.method_missing(method_symbol, *args) ⇒ Object

Using methods in configuration file and transform into hash keys



37
38
39
40
# File 'lib/xp5k/config.rb', line 37

def self.method_missing(method_symbol, *args)
  @@config[method_symbol] = args[0]
  @@config[method_symbol]
end