Module: Concerns::Statistical

Included in:
PriceManager
Defined in:
lib/concerns/concerns.rb

Instance Method Summary collapse

Instance Method Details

#basic_statsObject



101
102
103
104
105
106
107
108
109
110
# File 'lib/concerns/concerns.rb', line 101

def basic_stats
  values = yield.collect{|item| item.price}
  if values != []
    @stats[:volume] = values.count
    @stats[:mean] = values.reduce(:+)/@stats[:volume]
    @stats[:min] = values.min
    @stats[:max] = values.max
  end
  @stats
end