Module: Mathstats::Mixin

Defined in:
lib/mathstats.rb

Overview

All the class methods from Mathstats above are available in the Mixin module, via delegation. This module can be included in any class that has a method ‘#to_a` like Array

Class Method Summary collapse

Class Method Details

.delegate_to_mathstats(*symbols) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/mathstats.rb', line 59

def self.delegate_to_mathstats(*symbols)
  Array(symbols).each do |symbol|
    class_eval <<-EOS, __FILE__, __LINE__ + 1
      def #{symbol}(*args, &block)
        Mathstats.#{symbol}(self.to_a, *args, &block)
      end
    EOS
  end
end