module Knj::Rand

This module is used to handel various random handeling.

Public Class Methods

array(arr) click to toggle source

Returns a random element in the given array.

# File lib/knj/rand.rb, line 9
def self.array(arr)
  key = rand(arr.length)
  return arr[key]
end
range(first, last) click to toggle source

Returns a random integer between the two integers given.

# File lib/knj/rand.rb, line 4
def self.range(first, last)
  return first.to_i + rand(last.to_i - first.to_i)
end