Sha256: 4d0eee8b0f2b082b5f9fdceb32dc4f97ca14ef0cc0c84932e4ef1f9db48c89fb

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

module Outpost
  class Report
    # summarizes the list of statuses in a single status only.
    # The logic is rather simple - it will return the lowest status
    # present in the list.
    #
    # Examples:
    #
    # if passed [:up, :up, :up], will result on :up
    # if passed [:up, :down, :up], will result on :down
    def self.summarize(status_list)
      return :down if status_list.empty? || status_list.include?(:down)
      return :up
    end

    attr_reader :name, :description, :status

    def initialize(params)
      @name        = params[:name]
      @description = params[:description]
      @status      = params[:status]
    end

    def to_s
      "#{name}: '#{description}' is reporting #{status}."
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outpost-0.1.0 lib/outpost/report.rb