Method: Hitimes::Stats#to_hash

Defined in:
lib/hitimes/stats.rb

#to_hash(*args) ⇒ Object

call-seq:

stat.to_hash   -> Hash
stat.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.



122
123
124
125
126
127
128
129
130
# File 'lib/hitimes/stats.rb', line 122

def to_hash(*args)
  result = {}
  fields = [args].flatten
  fields = STATS if fields.empty?
  fields.each do |meth|
    result[meth] = send(meth)
  end
  result
end