Class: Jkr::Utils
- Inherits:
-
Object
- Object
- Jkr::Utils
- Defined in:
- lib/jkr/utils.rb
Class Method Summary collapse
Class Method Details
.reserve_next_dir(dir, suffix = "") ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jkr/utils.rb', line 31 def self.reserve_next_dir(dir, suffix = "") dirs = Dir.glob("#{dir}#{File::SEPARATOR}???*") max_num = -1 dirs.each do |dir| if /\A[0-9]+/ =~ File.basename(dir) max_num = [$~[0].to_i, max_num].max end end num = max_num + 1 dir = "#{dir}#{File::SEPARATOR}" + sprintf("%05d%s", num, suffix) FileUtils.mkdir(dir) dir end |