Methods
Classes and Modules
Module Random::String::Self
Public Class methods
included(base)
# File lib/more/facets/random.rb, line 315
    def self.included(base)
      base.extend(Self)
    end
Public Instance methods
at_rand( separator=// )

Return a random separation of the string. Default separation is by charaacter.

  "Ruby rules".at_rand(' ')  #=> ["Ruby"]
# File lib/more/facets/random.rb, line 363
    def at_rand( separator=// )
      #separator = self.class.patterns( separator )
      self.split(separator,-1).at_rand
    end
at_rand!( separator=// )

Return a random separation while removing it from the string. Default separation is by character.

  s = "Ruby rules"
  s = at_rand!(' ')  #=> "Ruby"
  s                  #=> "rules"
# File lib/more/facets/random.rb, line 375
    def at_rand!( separator=// )
      #separator = self.class.patterns( separator )
      a = self.shatter( separator )
      w = []; a.each_with_index { |s,i| i % 2 == 0 ? w << s : w.last << s }
      i = rand( w.size )
      r = w.delete_at( i )
      self.replace( w.join('') )
      return r
    end
rand_byte()

Return a random byte of self.

  "Ruby rules".rand_byte  #=> 121
# File lib/more/facets/random.rb, line 389
    def rand_byte
      self[rand( size )]
    end
rand_byte!()

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

  s = "Ruby rules"
  s.rand_byte!      #=> 121
  s                 #=> "Rub rules"
# File lib/more/facets/random.rb, line 399
    def rand_byte!
      i = rand( size )
      rv = self[i,1]
      self[i,1] = ''
      rv
    end
rand_index()

Return a random string index.

  "Ruby rules".rand_index  #=> 3
# File lib/more/facets/random.rb, line 410
    def rand_index
      rand( size )
    end
shuffle(separator=//)

Return the string with seperated sections arranged in a random order. The default seperation is by character.

  "Ruby rules".shuffle  #=> "e lybRsuur"
# File lib/more/facets/random.rb, line 419
    def shuffle(separator=//)
      split(separator).shuffle.join('')
    end
shuffle!(separator=//)

In place version of shuffle.

# File lib/more/facets/random.rb, line 425
    def shuffle!(separator=//)
      self.replace( shuffle(separator) )
    end