Module: ArrayHelpers
- Defined in:
- lib/nswtopo/helpers/array.rb
Instance Method Summary collapse
Instance Method Details
#in_two ⇒ Object
14 15 16 |
# File 'lib/nswtopo/helpers/array.rb', line 14 def in_two each_slice(1 + [length - 1, 0].max / 2) end |
#many? ⇒ Boolean
10 11 12 |
# File 'lib/nswtopo/helpers/array.rb', line 10 def many? length > 1 end |
#mean ⇒ Object
6 7 8 |
# File 'lib/nswtopo/helpers/array.rb', line 6 def mean empty? ? nil : inject(&:+) / length end |
#median ⇒ Object
2 3 4 |
# File 'lib/nswtopo/helpers/array.rb', line 2 def median sort[length / 2] end |