class Structura::Cfg
Public Instance Methods
is_string(target)
click to toggle source
# File lib/structura/cfg.rb, line 29 def is_string target raise ArgumentError, "Expected String Parameter: #{target}" if !target.instance_of? String end
load_file(file_path)
click to toggle source
# File lib/structura/cfg.rb, line 20 def load_file file_path raw_config = File.read(file_path) @cfg = YAML.load(raw_config) end
read_value(section, variable)
click to toggle source
# File lib/structura/cfg.rb, line 8 def read_value section, variable raise LoadError, 'Configuration file has not been loaded' if !@cfg is_string section is_string variable return false if !@cfg.include? section return false if !@cfg[section].include? string_to_symbol(variable) @cfg[section][string_to_symbol(variable)] end
string_to_symbol(string)
click to toggle source
# File lib/structura/cfg.rb, line 25 def string_to_symbol string string.to_s.downcase.gsub(/\s+/, "_").to_sym end