Module: DescriptiveStatistics::Support

Defined in:
lib/descriptive_statistics/support/convert.rb

Class Method Summary collapse

Class Method Details

.convert(from_enumerable) ⇒ Object



7
8
9
# File 'lib/descriptive_statistics/support/convert.rb', line 7

def self.convert(from_enumerable)
  extend to_float to_array from_enumerable
end

.extend(enumerable) ⇒ Object



17
18
19
# File 'lib/descriptive_statistics/support/convert.rb', line 17

def self.extend(enumerable)
  enumerable.extend(DescriptiveStatistics) 
end

.extract(from_enumerable) ⇒ Object



11
12
13
# File 'lib/descriptive_statistics/support/convert.rb', line 11

def self.extract(from_enumerable)
  extend to_array from_enumerable
end

.to_array(enumerable) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/descriptive_statistics/support/convert.rb', line 25

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) ⇒ Object



21
22
23
# File 'lib/descriptive_statistics/support/convert.rb', line 21

def self.to_float(enumerable)
  enumerable.map(&:to_f)
end