class Zabby::Config

Constants

SETTING_LIST

Public Class Methods

new() click to toggle source

Initialize Zabby configuration settings @todo Anything to configure here?

# File lib/rbZabbix/config.rb, line 12
def initialize
end

Public Instance Methods

list() click to toggle source

Display configuration variables

# File lib/rbZabbix/config.rb, line 16
def list
puts "Zabby configuration"
puts "==================="
  SETTING_LIST.each do |k|
    puts "#{k} = #{instance_variable_get("@#{k}")}"
  end
  nil
end
method_missing(name, *args, &block) click to toggle source

Dynamic setter and getter methods for the configuration variables. @param [String] name Setting name, ending with “=” in case we are setting a value @param [Array] args Setting value @param [Proc] block Unused @return [Object] Return the value set

# File lib/rbZabbix/config.rb, line 30
def method_missing(name, *args, &block)
  name = name.to_s.gsub(/=$/, '')
  raise ConfigurationError.new("Unknown setting '#{name}'") if !SETTING_LIST.include?(name.to_s)

  if args.empty?
    instance_variable_get("@#{name}")
  elsif args.size != 1
    raise ConfigurationError.new("Too many values for '#{name}'")
  else
    instance_variable_set("@#{name}", args.first)
  end
end