class Copy
Attributes
creation_date[R]
filename[R]
prefix[R]
target_path[R]
Public Class Methods
new(filename, prefix)
click to toggle source
# File lib/imagelib/copy2lib.rb, line 13 def initialize(filename, prefix) @filename = filename @prefix = prefix @creation_date = File.mtime(filename) @target_path = sprintf("%s/%d/%02d/%d-%02d-%02d", OUT_DIR, @creation_date.year, @creation_date.month, @creation_date.year, @creation_date.month, @creation_date.day) @target_filename = "#{@target_path}/#{@prefix}#{File.basename(@filename)}" @flag_filename = "#{@filename}.#{ENV['LOGNAME']}" end
Public Instance Methods
copy()
click to toggle source
# File lib/imagelib/copy2lib.rb, line 32 def copy if (work_to_do?) puts "#{@filename} -> #{@target_filename}" FileUtils::cp(@filename, @target_filename, :preserve=>true ) File.open(@flag_filename, 'w') { |file| } return @target_filename end end
prepare()
click to toggle source
# File lib/imagelib/copy2lib.rb, line 28 def prepare FileUtils::mkdir_p(@target_path) end
to_s()
click to toggle source
# File lib/imagelib/copy2lib.rb, line 46 def to_s return "#{@filename} with #{prefix}" end
work_to_do?()
click to toggle source
# File lib/imagelib/copy2lib.rb, line 41 def work_to_do? return !(File.exists?(@target_filename) or File.exists?(@flag_filename)) end