Class: Nagios::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/nagios/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/nagios/config.rb', line 8

def initialize
  @settings = {}
  @options = OptionParser.new do |options|
    options.on("-wWARNING",
               "--warning=WARNING",
               "Warning Threshold") do |x|
      @settings[:warning] = int_if_possible(x)
    end
    options.on("-cCRITICAL",
               "--critical=CRITICAL",
               "Critical Threshold") do |x|
      @settings[:critical] = int_if_possible(x)
    end
  end
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'lib/nagios/config.rb', line 6

def options
  @options
end

Instance Method Details

#[](setting) ⇒ Object



24
25
26
# File 'lib/nagios/config.rb', line 24

def [](setting)
  @settings[setting]
end

#[]=(field, value) ⇒ Object



28
29
30
# File 'lib/nagios/config.rb', line 28

def []=(field, value)
  @settings[field] = vaule
end

#parse!Object



32
33
34
# File 'lib/nagios/config.rb', line 32

def parse!
  @options.parse!
end