Module: Enumerable
- Defined in:
- lib/ctodo.rb
Instance Method Summary collapse
Instance Method Details
#avg ⇒ Object
35 36 37 |
# File 'lib/ctodo.rb', line 35 def avg (length == 0) ? 0 : (sum * 1.0 / length) end |
#median ⇒ Object
26 27 28 29 |
# File 'lib/ctodo.rb', line 26 def median sorted = self.sort sorted[self.length/2] end |
#sum ⇒ Object
31 32 33 |
# File 'lib/ctodo.rb', line 31 def sum self.inject(0) { |sum,v| sum + v } end |