### Home Classes Methods

### In Files

- lib/facets/random.rb

### Parent

Object

### Namespace

- MODULE Random::ArrayExtensions
- MODULE Random::HashExtensions
- MODULE Random::IntegerExtensions
- MODULE Random::NumericExtensions
- MODULE Random::RangeExtensions
- MODULE Random::StringExtensions

### Methods

- ::letter

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Random
- Random::ArrayExtensions
- Random::HashExtensions
- Random::IntegerExtensions
- Random::NumericExtensions
- Random::RangeExtensions
- Random::StringExtensions
- Random::StringExtensions::Self
- FileUtils
- FileUtils::DryRun
- FileUtils::NoWrite
- FileUtils::Verbose
- Digest
- Digest::Class
- Digest::Instance
- Multiton
- Multiton::Inclusive
- Multiton::MetaMethods
- URI
- URI::Hash
- URI::Kernel
- Argvector
- Argvector
- ERB
- ERB::OpenTemplate
- Enumerable
- Enumerable::Arguments
- GetoptLong
- GetoptLong::DSL
- Memoizable
- Memoizable::Copy
- Numeric
- Numeric::Multipliers
- Object
- Object::ArgVector
- Timer
- Timer::Dummy
- Array
- BasicObject
- CGI
- Cloneable
- Continuation
- Date
- DateTime
- Equitable
- File
- Find
- Hash
- Instantiable
- Integer
- Interval
- Kernel
- Math
- Module
- Net
- NilClass
- NullClass
- OpEsc
- OpenStruct
- Pathname
- Platform
- Range
- RbConfig
- Set
- Shellwords
- String
- StringScanner
- Time
- Tuple
- YAML
- Zlib

No matching classes.

# Random

# Randomization Extensions

This library extends Array, String, Hash and other classes 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 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.

The classes are all extended via mixins which have been created within Ruby's Random class.

Credit for this work is due to:

- Ilmari Heikkinen

- Christian Neukirchen

- Thomas Sawyer

NOTE: Inline QED tests are almost pointless here b/c... yea, it's random. So indtead of the usual `#=>` we use `#~>` which means approx. equal and prevens QED from making a hard assertion.

### Public Class Methods

letter() click to toggle source

Module method to generate a random letter.

    Random.letter  #~> "q"
    Random.letter  #~> "r"
    Random.letter  #~> "a"

    # File lib/facets/random.rb, line 50
    def self.letter
      (Random.number(26) + (Random.number(2) == 0 ? 65 : 97) ).chr
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.