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.116 lib/knj/rand.rb
knjrbfw-0.0.115 lib/knj/rand.rb
knjrbfw-0.0.114 lib/knj/rand.rb
knjrbfw-0.0.113 lib/knj/rand.rb
knjrbfw-0.0.111 lib/knj/rand.rb
knjrbfw-0.0.110 lib/knj/rand.rb
knjrbfw-0.0.109 lib/knj/rand.rb
knjrbfw-0.0.108 lib/knj/rand.rb
knjrbfw-0.0.107 lib/knj/rand.rb
knjrbfw-0.0.105 lib/knj/rand.rb
knjrbfw-0.0.104 lib/knj/rand.rb
knjrbfw-0.0.103 lib/knj/rand.rb
knjrbfw-0.0.102 lib/knj/rand.rb
knjrbfw-0.0.101 lib/knj/rand.rb
knjrbfw-0.0.100 lib/knj/rand.rb
knjrbfw-0.0.99 lib/knj/rand.rb
knjrbfw-0.0.98 lib/knj/rand.rb
knjrbfw-0.0.97 lib/knj/rand.rb
knjrbfw-0.0.96 lib/knj/rand.rb
knjrbfw-0.0.95 lib/knj/rand.rb