Module: NagiosCheck::Chronometer

Included in:
NagiosCheck
Defined in:
lib/nagios_check/chronometer.rb

Instance Method Summary collapse

Instance Method Details

#time(opts = {}, &block) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
# File 'lib/nagios_check/chronometer.rb', line 5

def time(opts = {}, &block)
  raise ArgumentError, "block is mandatory for method time" if block.nil?
  time = Benchmark.realtime { block.call }
  if opts[:value_name]
    store_value(opts[:value_name], time)
  end
  time
end