class Configuration

The Config class is a singleton that allows class level configuration

Attributes

options[R]

Public Class Methods

new() click to toggle source
# File lib/utility/configuration.rb, line 23
def initialize
  $cmdopts = get_options
  @options = YAML::load_file($cmdopts['configfile'] || 'config.yaml')
rescue
  $stderr.puts "WARNING - configuration file not found"
  @options = {}
end

Public Instance Methods

get_options() click to toggle source

only process configuration file option from command line

# File lib/utility/configuration.rb, line 32
def get_options
  myopts = {}
  ARGV.each_with_index do |arg,i|
    if (arg == '-c' || arg == '--config') && ARGV[i+1]
      myopts['configfile'] = ARGV[i+1]
      ARGV.delete_at(i+1)
      ARGV.delete_at(i)
    end
  end
  myopts
end