Sha256: 5fc5ab9a0f44ceb6455b13a086f3ee5d0f7fc305480b7906d7c5d742d8b96086

Contents?: true

Size: 352 Bytes

Versions: 79

Compression:

Stored size: 352 Bytes

Contents

#This module is used to handel various random handeling.
module Knj::Rand
  #Returns a random integer between the two integers given.
  def self.range(first, last)
    return first.to_i + rand(last.to_i - first.to_i)
  end
  
  #Returns a random element in the given array.
  def self.array(arr)
    key = rand(arr.length)
    return arr[key]
  end
end

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
knjrbfw-0.0.94 lib/knj/rand.rb
knjrbfw-0.0.93 lib/knj/rand.rb
knjrbfw-0.0.92 lib/knj/rand.rb
knjrbfw-0.0.91 lib/knj/rand.rb
knjrbfw-0.0.90 lib/knj/rand.rb
knjrbfw-0.0.89 lib/knj/rand.rb
knjrbfw-0.0.88 lib/knj/rand.rb
knjrbfw-0.0.87 lib/knj/rand.rb
knjrbfw-0.0.86 lib/knj/rand.rb
knjrbfw-0.0.85 lib/knj/rand.rb
knjrbfw-0.0.84 lib/knj/rand.rb
knjrbfw-0.0.83 lib/knj/rand.rb
knjrbfw-0.0.82 lib/knj/rand.rb
knjrbfw-0.0.81 lib/knj/rand.rb
knjrbfw-0.0.80 lib/knj/rand.rb
knjrbfw-0.0.79 lib/knj/rand.rb
knjrbfw-0.0.78 lib/knj/rand.rb
knjrbfw-0.0.77 lib/knj/rand.rb
knjrbfw-0.0.75 lib/knj/rand.rb
knjrbfw-0.0.74 lib/knj/rand.rb