Method: Random::StringExtensions#rand_byte!

Defined in:
lib/garcon/core_ext/random.rb

#rand_byte!Object

Destructive rand_byte. Delete a random byte of self and return it.

Examples:

s = "Ruby rules"
s.rand_byte!      # => 121
s                 # => "Rub rules"


458
459
460
461
462
463
# File 'lib/garcon/core_ext/random.rb', line 458

def rand_byte!
  i = SecureRandom.random_number(size)
  rv = self[i,1]
  self[i,1] = ''
  rv
end