Method: String.random
- Defined in:
- lib/kiss/ext/core.rb
.random(length) ⇒ Object
Generates string of random text of the specified length.
567 568 569 570 571 572 573 574 575 |
# File 'lib/kiss/ext/core.rb', line 567 def random(length) chars = [('A'..'H'), ('J'..'N'), ('P'..'R'), ('T'..'Y'), ('3'..'4'), ('6'..'9')].map {|r| r.to_a }.flatten # array text = '' size = chars.size length.times { text += chars[rand(size)] } text end |