Module: Id2path

Defined in:
lib/id2path.rb

Instance Method Summary collapse

Instance Method Details

#create_path(root) ⇒ Object



3
4
5
6
7
8
# File 'lib/id2path.rb', line 3

def create_path root
	dir1, dir2, file = self.id.to_s.rjust(9, '0').scan(/\d{3}/)
	Dir.mkdir(File.join(root, dir1)) unless File.directory?(File.join(root, dir1))
	Dir.mkdir(File.join(root, dir1, dir2)) unless File.directory?(File.join(root, dir1, dir2))
	File.join(root, dir1, dir2, file)
end