Module: NagiosCheck::ClassMethods
- Defined in:
- lib/nagios_check.rb
Instance Method Summary collapse
- #check_options!(options) ⇒ Object
- #defaults ⇒ Object
- #enable_critical(*args) ⇒ Object
- #enable_timeout(*args) ⇒ Object
- #enable_warning(*args) ⇒ Object
- #on(*args, &block) ⇒ Object
Instance Method Details
#check_options!(options) ⇒ Object
133 134 135 136 137 138 139 140 |
# File 'lib/nagios_check.rb', line 133 def () @option_specs.each do |name, spec| _, option_params, _ = spec if option_params[:mandatory] && .send(name).nil? raise MissingOption.new(name) end end end |
#defaults ⇒ Object
111 112 113 |
# File 'lib/nagios_check.rb', line 111 def defaults @defaults end |
#enable_critical(*args) ⇒ Object
121 122 123 124 125 |
# File 'lib/nagios_check.rb', line 121 def enable_critical(*args) on("-c RANGE", *args) do |value| self..c = NagiosCheck::Range.new(value) end end |
#enable_timeout(*args) ⇒ Object
127 128 129 130 131 |
# File 'lib/nagios_check.rb', line 127 def enable_timeout(*args) on("-t TIMEOUT", *args) do |value| self..t = value.to_f end end |
#enable_warning(*args) ⇒ Object
115 116 117 118 119 |
# File 'lib/nagios_check.rb', line 115 def enable_warning(*args) on("-w RANGE", *args) do |value| self..w = NagiosCheck::Range.new(value) end end |
#on(*args, &block) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/nagios_check.rb', line 99 def on(*args, &block) name = option_name(args.first) option_params = { :mandatory => args.delete(:mandatory) ? true : false } if args.last.respond_to? :has_key? option_params.merge! args.pop end @defaults[name] = option_params[:default] if option_params.has_key? :default @option_specs[name] = [args, option_params, block] end |