Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/joule/array.rb

Instance Method Summary collapse

Instance Method Details

#averageObject



11
12
13
# File 'lib/joule/array.rb', line 11

def average
  summation/length
end

#average_maximum(size) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/joule/array.rb', line 15

def average_maximum(size)
  mean_max = {:start => 0.0, :value=> 0.0}
    each_index do |i|
      mean = slice(i, size).average
      mean > mean_max[:value] &&  mean_max = {:start => i, :value => mean}
    end
  mean_max
end

#maximumObject



7
8
9
# File 'lib/joule/array.rb', line 7

def maximum
  inject {|max, value| value>max ? value : max}
end

#summationObject



2
3
4
5
# File 'lib/joule/array.rb', line 2

def summation
  inject{|sum, value| 
    sum + value}
end