module Umruhren

Constants

CHARS
VERSION

Public Class Methods

rename_files(dir, ext) click to toggle source
# File lib/umruhren.rb, line 8
def rename_files(dir, ext)
  files = Dir[dir + "/*.#{ext}"]
  new_names = rand_string_array(files.size)
  files.each_with_index do |f, i|
    File.rename(f, dir + "/" + new_names[i] + File.extname(f))
  end
end

Private Class Methods

rand_string(length = 12) click to toggle source
# File lib/umruhren.rb, line 17
def rand_string(length = 12)
  (1..length).map{ CHARS.sample }.join
end
rand_string_array(size) click to toggle source
# File lib/umruhren.rb, line 21
def rand_string_array(size)
  randoms = Set.new
  loop do
    randoms << rand_string
    return randoms.to_a if randoms.size >= size
  end
end