Module: Knj::Rand

Defined in:
lib/knj/rand.rb

Class Method Summary collapse

Class Method Details

.array(arr) ⇒ Object



6
7
8
9
# File 'lib/knj/rand.rb', line 6

def self.array(arr)
  key = rand(arr.length)
  return arr[key]
end

.range(first, last) ⇒ Object



2
3
4
# File 'lib/knj/rand.rb', line 2

def self.range(first, last)
  return first.to_i + rand(last.to_i - first.to_i)
end