Parent

RBatch::Config

Public Class Methods

new(path) click to toggle source
# File lib/rbatch/config.rb, line 9
def initialize(path)
  @path = path
  begin
    @hash = YAML::load_file(@path)
  rescue Errno::ENOENT => e
    @hash = nil
  end
end

Public Instance Methods

[](key) click to toggle source
# File lib/rbatch/config.rb, line 17
def[](key)
  if @hash.nil?
    raise RBatch::ConfigException, "Config file \"#{@path}\" does not exist"
  end
  if @hash[key].nil?
    if key.class == Symbol
      raise RBatch::ConfigException, "Value of key(:#{key} (Symbol)) is nil. By any chance, dou you mistake key class Symbol for String?"
    elsif key.class == String
      raise RBatch::ConfigException, "Value of key(\"#{key}\" (String)) is nil"
    else
      raise RBatch::ConfigException, "Value of key(#{key}) is nil."
    end
  else
    @hash[key]
  end
end
exist?() click to toggle source
# File lib/rbatch/config.rb, line 34
def exist? ; ! @hash.nil? ; end
path() click to toggle source
# File lib/rbatch/config.rb, line 33
def path ; @path ; end
to_h() click to toggle source
# File lib/rbatch/config.rb, line 35
def to_h
  if @hash.nil?
    raise RBatch::ConfigException, "Config file \"#{@path}\" does not exist"
  else
    @hash
  end
end
to_s() click to toggle source
# File lib/rbatch/config.rb, line 42
def to_s
  if @hash.nil?
    raise RBatch::ConfigException, "Config file \"#{@path}\" does not exist"
  else
    @hash.to_s
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.