Parent

Namespace

RBatch::RunConf

Attributes

path[RW]

Public Class Methods

new(path=nil) click to toggle source
# File lib/rbatch/run_conf.rb, line 30
def initialize(path=nil)
  if path.nil?
    @opt = @@def_opt.clone
  else
    @path = path
    @opt = @@def_opt.clone
    load
  end
end

Public Instance Methods

[](key) click to toggle source
# File lib/rbatch/run_conf.rb, line 84
def[](key)
  if @opt[key].nil?
    raise RBatch::RunConf::Exception, "Value of key=\"#{key}\" is nil"
  end
  @opt[key]
end
[]=(key,value) click to toggle source
# File lib/rbatch/run_conf.rb, line 91
def[]=(key,value)
  if ! @opt.has_key?(key)
    raise RBatch::RunConf::Exception, "Key=\"#{key}\" does not exist"
  end
  @opt[key]=value
end
has_key?(key) click to toggle source
# File lib/rbatch/run_conf.rb, line 58
def has_key?(key)
  @opt.has_key?(key)
end
load() click to toggle source
# File lib/rbatch/run_conf.rb, line 40
def load()
  begin
    @yaml = YAML::load_file(@path)
  rescue
    # when run_conf does not exist, do nothing.
    @yaml = false
  end
  if @yaml
    @yaml.each_key do |key|
      if @@def_opt.has_key?(key.to_sym)
        @opt[key.to_sym]=@yaml[key]
      else
        raise RBatch::RunConf::Exception, "\"#{key}\" is not available option"
      end
    end
  end
end
merge(opt) click to toggle source
# File lib/rbatch/run_conf.rb, line 72
def merge(opt)
  tmp = @opt.clone
  opt.each_key do |key|
    if tmp.has_key?(key)
      tmp[key] = opt[key]
    else
      raise RBatch::RunConf::Exception, "\"#{key}\" is not available option"
    end
  end
  return tmp
end
merge!(opt) click to toggle source
# File lib/rbatch/run_conf.rb, line 62
def merge!(opt)
  opt.each_key do |key|
    if @opt.has_key?(key)
      @opt[key] = opt[key]
    else
      raise RBatch::RunConf::Exception, "\"#{key}\" is not available option"
    end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.