Class: Ibsenphrase::Random

Inherits:
Object
  • Object
show all
Defined in:
lib/ibsenphrase/random.rb

Overview

This encapsulates the pseudo-random number generator (PRNG), essentially turning it into a singleton class. This is done to avoid instantiating a new PRNG every time we need it, as that would make us dependent on the randomness of the operating system’s seed, instead of the random number generator code in Ruby.

Class Method Summary collapse

Class Method Details

.prngObject



8
9
10
# File 'lib/ibsenphrase/random.rb', line 8

def self.prng
  @@rng ||= ::Random.new
end