Sha256: 37a5718aa4042678e2f82e9a73d42bbc984ec9ca7ba56008ec169ee40b7b97d4

Contents?: true

Size: 757 Bytes

Versions: 38

Compression:

Stored size: 757 Bytes

Contents

module Oxidized
  class Node
    class Stats
      MAX_STAT = 10

      # @param [Job] job job whose information add to stats
      # @return [void]
      def add job
        stat = {
          :start  => job.start,
          :end    => job.end,
          :time   => job.time,
        }
        @stats[job.status] ||= []
        @stats[job.status].shift if @stats[job.status].size > MAX_STAT
        @stats[job.status].push stat
      end

      # @param [Symbol] status stats for specific status
      # @return [Hash,Array] Hash of stats for every status or Array of stats for specific status
      def get status=nil
        status ? @stats[status] : @stats
      end

      private

      def initialize
        @stats = {}
      end

    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
oxidized-0.21.0 lib/oxidized/node/stats.rb
oxidized-0.20.0 lib/oxidized/node/stats.rb
oxidized-0.19.0 lib/oxidized/node/stats.rb
oxidized-0.18.0 lib/oxidized/node/stats.rb
oxidized-0.17.0 lib/oxidized/node/stats.rb
oxidized-0.16.3 lib/oxidized/node/stats.rb
oxidized-0.16.2 lib/oxidized/node/stats.rb
oxidized-0.16.1 lib/oxidized/node/stats.rb
oxidized-0.16.0 lib/oxidized/node/stats.rb
oxidized-0.15.0 lib/oxidized/node/stats.rb
oxidized-0.14.3 lib/oxidized/node/stats.rb
oxidized-0.14.2 lib/oxidized/node/stats.rb
oxidized-0.14.1 lib/oxidized/node/stats.rb
oxidized-0.14.0 lib/oxidized/node/stats.rb
oxidized-0.13.1 lib/oxidized/node/stats.rb
oxidized-0.13.0 lib/oxidized/node/stats.rb
oxidized-0.12.2 lib/oxidized/node/stats.rb
oxidized-0.12.1 lib/oxidized/node/stats.rb
oxidized-0.12.0 lib/oxidized/node/stats.rb
oxidized-0.11.0 lib/oxidized/node/stats.rb