Class: Hitimes::Stats

### Home Classes Methods

### In Files

- lib/hitimes/stats.rb

### Parent

Object

### Methods

- #to_hash
- #to_json

### Files

- Manifest.txt

### Class/Module Index

Quicksearch

- Hitimes
- Hitimes::Error
- Hitimes::Metric
- Hitimes::MutexedStats
- Hitimes::Paths
- Hitimes::Stats
- Hitimes::TimedMetric
- Hitimes::TimedValueMetric
- Hitimes::ValueMetric

No matching classes.

# Hitimes::Stats

### Constants

STATS

  A list of the available stats

### Public Instance Methods

to_hash → Hash click to toggle source
to_hash( %w[ count max mean ]) → Hash

return a hash of the stats. By default this returns a hash of all stats but passing in an array of items will limit the stats returned to only those in the Array.

If passed in an empty array or nil to to_hash then STATS is assumed to be the list of stats to return in the hash.

    # File lib/hitimes/stats.rb, line 24
    def to_hash( *args )
      h = {}
      args = [ args ].flatten
      args = STATS if args.empty?
      args.each do |meth|
        h[meth] = self.send( meth )
      end
      return h
    end

to_json → String click to toggle source
to_json( *args ) → String

return a json string of the stats. By default this returns a json string of all the stats. If an array of items is passed in, those that match the known stats will be all that is included in the json output.

    # File lib/hitimes/stats.rb, line 43
    def to_json( *args )
      h = to_hash( *args )
      a = []
      s = StringIO.new

      s.print "{ "
      h.each_pair do |k,v|
        a << "\"#{k}\": #{v}"
      end
      s.print a.join(", ")
      s.print "}"
      return s.string
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.