Module: Statistical::Rng

Defined in:
lib/statistical/rng.rb,
lib/statistical/rng/laplace.rb,
lib/statistical/rng/uniform.rb,
lib/statistical/rng/weibull.rb,
lib/statistical/rng/bernoulli.rb,
lib/statistical/rng/two_point.rb,
lib/statistical/rng/exponential.rb,
lib/statistical/rng/uniform_discrete.rb

Overview

Factory module to create instances of the various classes nested under itself

Defined Under Namespace

Classes: Bernoulli, Exponential, Laplace, TwoPoint, Uniform, UniformDiscrete, Weibull

Class Method Summary collapse

Class Method Details

.const_missing(cname) ⇒ Object

No need to document this Dynamically add constants when called



16
17
18
# File 'lib/statistical/rng.rb', line 16

def self.const_missing(cname)
  const_set(cname, make_classmap) if cname == :RNG_TYPES
end

.create(type = :uniform, *args, &block) ⇒ Object

Creates a new instance of the give type if the type was found.

Raises:

  • ArgumentError If the give type parameter was not found



23
24
25
26
# File 'lib/statistical/rng.rb', line 23

def self.create(type = :uniform, *args, &block)
  raise ArgumentError unless RNG_TYPES.include?(type)
  RNG_TYPES[type].new(*args, &block)
end