Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/audit/lib/util/random_string.rb
Overview
Ruby 1.8 does not contains sample() function NB:
- ruby 1.8.6 has no equivalent method
- ruby 1.8.7 has choice() method
- ruby 1.9 has sample() method
Instance Method Summary collapse
Instance Method Details
#sec_sample ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/audit/lib/util/random_string.rb', line 10 def sec_sample() if self.respond_to?(:sample, true) return self.sample() elsif self.respond_to?(:choice, true) return self.choice() else return (('A' .. 'Z').to_a + ('a' .. 'z').to_a + ('0' .. '9').to_a)[Kernel.srand.modulo(62)] end end |