rand

Shuffle and pick elements at random.

Overview

Hello, world.

rand is a library for Ruby, provided under the terms of the Ruby license.  It should not be confused with the Kernel#rand method in Ruby core.

This library provides helper methods mixed in to Enumerable, Array, Hash, and String.  These methods allow you to easily shuffle the order of elements or pick an element at random.

It should be noted that the Facets project includes some functionality similar to this library, although the algorithms used are different.  This library should be considered a lightweight alternative.

Features

Methods are provided to:

It also provides these facilities in String:

Get It

Currently there are two ways to get the rand library:

  1. Install the RubyGem. Recommended. Just do this:

    gem install rand

    That's it. Enjoy!

  2. Download from RubyForge.  tgz and zip files are available in the Files section.

    A standard setup.rb installer script is provided:

    ruby setup.rb

    You may need superuser access to run the installer, depending on your system configuration.

  3. Check out the latest code from the Subversion repository.

    The repository URI for the latest library code in Subversion (known as the 'trunk') is:

    svn://rubyforge.org/var/svn/rand/trunk/rand

    You'll want to use this method if you are interested in following the development of the rand library or if you just want to try out the latest code.  The code in Subversion should always work, but no guarantee can be made since it is expected to change frequently.

    A Subversion client is required to check out code from the repository.  Many different clients are available; you should select an appropriate client for your development environment.  Once a client has been installed, run the checkout command.  See the documentation for your chosen client for details.  Provide the repository URI (noted above) when requested.

    For example, with the classic command line Subversion client, you would run a command like this:

    svn checkout svn://rubyforge.org/var/svn/rand/trunk/rand

Resources

History

Authors

Copyright 2007 Keegan Quinn.  This page can be redistributed and/or modified under the terms of the WTFPL.  It comes without any warranty, to the extent permitted by applicable law.