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



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

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

.[]=(opt, value) ⇒ Object

Configuration options setter



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

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

.loadObject

Load the experiment configuration file



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

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

.loaded?Boolean

def

self.load

Returns:

  • (Boolean)


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

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

.method_missing(method_symbol, *args) ⇒ Object

Using methods in configuration file and transform into hash keys



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

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