lib/garcon/core_ext/random.rb
# Return a random separation while removing it from the string. Default
# separation is by character.
#
# @example
#   s = "Ruby rules"
#   s.at_rand!(' ')    # => "Ruby"
#   s                  # => "rules"
#
Return a random separation while removing it from the string. Default
separation is by character.
Return a random separation while removing it from the string . Default separation is by character .
def at_rand!(separator = //)
      a = self.shatter(separator)
      w = []; a.each_with_index { |s, i| i % 2 == 0 ? w << s : w.last << s }
      i = SecureRandom.random_number(w.size)
      r = w.delete_at(i)
      self.replace(w.join(''))
      return r
    end
def at_rand! ( separator = / / ) a = self . shatter ( separator ) w = [ ] ; a . each_with_index { | s , i | i % 2 == 0 ? w << s : w . last << s } i = SecureRandom . random_number ( w . size ) r = w . delete_at ( i ) self . replace ( w . join ( '' ) ) return r end
Return a random separation while removing it from the string.
Return a random separation while removing it from the string .
separator
<not_specific>
example
None