module DescriptiveStatistics::Support
Public Class Methods
convert(from_enumerable, &block)
click to toggle source
# File lib/descriptive_statistics/support/convert.rb, line 7 def self.convert(from_enumerable, &block) extend to_float to_value(to_array(from_enumerable), &block) end
extract(from_enumerable, &block)
click to toggle source
# File lib/descriptive_statistics/support/convert.rb, line 11 def self.extract(from_enumerable, &block) extend to_value(to_array(from_enumerable), &block) end
Private Class Methods
extend(enumerable)
click to toggle source
# File lib/descriptive_statistics/support/convert.rb, line 17 def self.extend(enumerable) enumerable.extend(DescriptiveStatistics) end
to_array(enumerable)
click to toggle source
# File lib/descriptive_statistics/support/convert.rb, line 30 def self.to_array(enumerable) case enumerable when Hash enumerable.values.each when Set enumerable.to_a.each else enumerable.each end end
to_float(enumerable)
click to toggle source
# File lib/descriptive_statistics/support/convert.rb, line 21 def self.to_float(enumerable) enumerable.map(&:to_f) end
to_value(enumerable) { |object| ... }
click to toggle source
# File lib/descriptive_statistics/support/convert.rb, line 25 def self.to_value(enumerable, &block) return enumerable unless block_given? enumerable.map { |object| yield object } end