Class: Oxidized::Node::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/oxidized/node/stats.rb

Constant Summary collapse

MAX_STAT =
10

Instance Method Summary collapse

Instance Method Details

#add(job) ⇒ void

This method returns an undefined value.

Parameters:

  • job (Job)

    job whose information add to stats



8
9
10
11
12
13
14
15
16
17
# File 'lib/oxidized/node/stats.rb', line 8

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

#get(status = nil) ⇒ Hash, Array

Returns Hash of stats for every status or Array of stats for specific status.

Parameters:

  • status (Symbol) (defaults to: nil)

    stats for specific status

Returns:

  • (Hash, Array)

    Hash of stats for every status or Array of stats for specific status



21
22
23
# File 'lib/oxidized/node/stats.rb', line 21

def get status=nil
  status ? @stats[status] : @stats
end