Sha256: db72a0c42f84485255cffe597e5586ab41520c7ea74cbb37bf9c66e547b40bdd
Contents?: true
Size: 951 Bytes
Versions: 2
Compression:
Stored size: 951 Bytes
Contents
module NagiosPlugin # A custom status error which will be raised through the status methods. class StatusError < StandardError # All allowed statuses sorted by their corresponding exit status. STATUS = [:ok, :warning, :critical, :unknown] # @param [Symbol] status the status (must be {NagiosPlugin::Plugin::StatusError::STATUS a valid status}) # @param [String] message the message you want to display def initialize(status, message) @status, @message = status.to_sym, message end # @return [String] the status and message def to_s "#{status.to_s.upcase}: #{@message}" end # @return [Fixnum] the status converted into an exit code def to_i STATUS.find_index(status) end private # @return [Symbol] the status (:unknown if invalid) def status (STATUS.include?(@status) && @status) || STATUS.last end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nagiosplugin-1.1.1 | lib/nagiosplugin/status_error.rb |
nagiosplugin-1.1.0 | lib/nagiosplugin/status_error.rb |