Sha256: 6c8e3c1c6cbb65f56e05d2bfebb782d74faa816f8cee389821211ed5367d3485

Contents?: true

Size: 1.06 KB

Versions: 17

Compression:

Stored size: 1.06 KB

Contents

#!/usr/bin/env ruby

module Flapjack
  module Transport
    class Result

      attr_accessor :job, :result

      def initialize(options={})
        @job = options[:job]
        @result = OpenStruct.new(options[:result])
      end

      # Whether a check returns an ok status.
      def ok?
        @result.retval == 0
      end

      # Whether a check has a warning status.
      def warning?
        @result.retval == 1
      end

      # Whether a check has a critical status.
      def critical?
        @result.retval == 2
      end

      # Human readable representation of the check's return value.
      def status
        case @result.retval
        when 0 ; "ok"
        when 1 ; "warning"
        when 2 ; "critical"
        end
      end

      # FIXME: there is a *lot* of duplication here - implement a proxy
      # object pattern?
      def id
        @result.check_id
      end

      def check_id
        @result.check_id
      end

      def command
        @result.command
      end

      def frequency
        @result.frequency
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
flapjack-0.6.39 lib/flapjack/transports/result.rb
flapjack-0.6.38 lib/flapjack/transports/result.rb
flapjack-0.6.37 lib/flapjack/transports/result.rb
flapjack-0.6.36 lib/flapjack/transports/result.rb
flapjack-0.6.35 lib/flapjack/transports/result.rb
flapjack-0.6.34 lib/flapjack/transports/result.rb
flapjack-0.6.33 lib/flapjack/transports/result.rb
flapjack-0.6.32 lib/flapjack/transports/result.rb
flapjack-0.6.31 lib/flapjack/transports/result.rb
flapjack-0.6.30 lib/flapjack/transports/result.rb
flapjack-0.6.29 lib/flapjack/transports/result.rb
flapjack-0.6.28 lib/flapjack/transports/result.rb
flapjack-0.6.27 lib/flapjack/transports/result.rb
flapjack-0.6.26 lib/flapjack/transports/result.rb
flapjack-0.6.25 lib/flapjack/transports/result.rb
flapjack-0.6.24 lib/flapjack/transports/result.rb
flapjack-0.6.23 lib/flapjack/transports/result.rb