Module: Renchin::FileProcessor
Instance Method Summary collapse
-
#delete_directory(image_directory_path, expr) ⇒ Object
delete all files in directory.
- #exists?(filename) ⇒ Boolean
-
#image_directory(method_name) ⇒ Object
create temporary directory for frame images.
- #init_file(filename) ⇒ Object
Instance Method Details
#delete_directory(image_directory_path, expr) ⇒ Object
delete all files in directory
12 13 14 15 16 17 18 19 |
# File 'lib/renchin/file_processor.rb', line 12 def delete_directory(image_directory_path,expr) if exists?(image_directory_path) Dir::foreach(image_directory_path) do |file| File.delete(image_directory_path + '/' + file) if (/#{expr}$/ =~ file) end Dir::rmdir(image_directory_path) end end |
#exists?(filename) ⇒ Boolean
21 22 23 |
# File 'lib/renchin/file_processor.rb', line 21 def exists?(filename) File.exist?(filename) end |
#image_directory(method_name) ⇒ Object
create temporary directory for frame images
5 6 7 8 9 |
# File 'lib/renchin/file_processor.rb', line 5 def image_directory(method_name) = "/tmp/renchin_#{method_name}_#{Time.now.to_i}" Dir::mkdir(,0777) end |
#init_file(filename) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/renchin/file_processor.rb', line 25 def init_file(filename) unless File.exist?(filename) dir = File.dirname(filename) unless File.exist?(dir) FileUtils.mkdir_p(dir) end end true end |