module Random

Random

Randomization core extension methods.

This library extends Array, String and Hash with randomization methods. Most of the methods are of one of two kinds. Either they “pick” a random element from the reciever or they randomly “shuffle” the reciever.

The most common example is Random::Array#shuffle, which simply randmomizes the order of an array's elements.

[1,2,3].shuffle  #=> [2,3,1]

The other methods do similar things for their respective classes.

Public Class Methods

append_features(mod) click to toggle source
# File lib/more/facets/random.rb, line 66
def self.append_features(mod)
  if mod == ::Object
    mod.send(:include, Random::Object)
  elsif mod == ::Range
    mod.send(:include, Random::Range)
  elsif mod == ::Array
    mod.send(:include, Random::Array)
  elsif mod == ::Hash
    mod.send(:include, Random::Hash)
  elsif mod == ::String
    mod.send(:include, Random::String)
  else
    raise TypeError
  end
end