Class: Random

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

Class Method Summary collapse

Class Method Details

.rand_str(length) ⇒ Object

随机长度的字符串



4
5
6
# File 'lib/core_extend/random.rb', line 4

def self.rand_str(length)
  length.times.inject('') { |acc, i| acc+=(('a'..'z').to_a+('0'..'9').to_a)[(i+Random.rand(1000))%36]; acc }
end