class RBatch::RunConf
@private
Attributes
path[RW]
Public Class Methods
new(path=nil)
click to toggle source
# File lib/rbatch/run_conf.rb, line 33 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 87 def[](key) if @opt[key].nil? raise RBatch::RunConfException, "Value of key=\"#{key}\" is nil" end @opt[key] end
[]=(key,value)
click to toggle source
# File lib/rbatch/run_conf.rb, line 94 def[]=(key,value) if ! @opt.has_key?(key) raise RBatch::RunConfException, "Key=\"#{key}\" does not exist" end @opt[key]=value end
has_key?(key)
click to toggle source
# File lib/rbatch/run_conf.rb, line 61 def has_key?(key) @opt.has_key?(key) end
load()
click to toggle source
# File lib/rbatch/run_conf.rb, line 43 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::RunConfException, "\"#{key}\" is not available option" end end end end
merge(opt)
click to toggle source
# File lib/rbatch/run_conf.rb, line 75 def merge(opt) tmp = @opt.clone opt.each_key do |key| if tmp.has_key?(key) tmp[key] = opt[key] else raise RBatch::RunConfException, "\"#{key}\" is not available option" end end return tmp end
merge!(opt)
click to toggle source
# File lib/rbatch/run_conf.rb, line 65 def merge!(opt) opt.each_key do |key| if @opt.has_key?(key) @opt[key] = opt[key] else raise RBatch::RunConfException, "\"#{key}\" is not available option" end end end