Sha256: 5d06553c6caa74b32574ba212c3446b5ab6e0d2043ce0887509e7c86b485b0b7
Contents?: true
Size: 700 Bytes
Versions: 2
Compression:
Stored size: 700 Bytes
Contents
require File.expand_path("../signal_tools/stock_data", __FILE__) require File.expand_path("../signal_tools/stock", __FILE__) module SignalTools VERSION = '0.2.0' def self.sum(array) array.inject(0) {|accum, c| accum + c.to_f } end def self.average(array) return nil if !array || array.size == 0 sum(array).to_f / array.size end # Truncates all arrays to the size of the shortest array by cutting off the front # of the longer arrays. def self.truncate_to_shortest!(*arrays) shortest_size = arrays.inject(arrays.first.size) { |size, array| array.size < size ? array.size : size } arrays.each { |array| array.slice!(0...(array.size - shortest_size)) } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
signal_tools-0.2.1 | lib/signal_tools.rb |
signal_tools-0.2.0 | lib/signal_tools.rb |