Class: Bubbles::BubbliciousFile
- Inherits:
-
Object
- Object
- Bubbles::BubbliciousFile
- Extended by:
- Forwardable
- Defined in:
- lib/bubbles/bubblicious_file.rb
Instance Method Summary collapse
- #copy_to_processing_dir ⇒ Object
-
#initialize(file:, config:) ⇒ BubbliciousFile
constructor
A new instance of BubbliciousFile.
- #metadata ⇒ Object
- #remove_file ⇒ Object
- #uid_file ⇒ Object
- #uid_file_name ⇒ Object
Constructor Details
#initialize(file:, config:) ⇒ BubbliciousFile
Returns a new instance of BubbliciousFile.
5 6 7 8 |
# File 'lib/bubbles/bubblicious_file.rb', line 5 def initialize(file:, config:) @file = file @config = config end |
Instance Method Details
#copy_to_processing_dir ⇒ Object
10 11 12 13 |
# File 'lib/bubbles/bubblicious_file.rb', line 10 def copy_to_processing_dir config.logger.debug("BubbliciousFile: copy file #{file} to #{uid_file}") FileUtils.cp(file, uid_file) end |
#metadata ⇒ Object
22 23 24 |
# File 'lib/bubbles/bubblicious_file.rb', line 22 def { original_name: file.basename.to_s } end |
#remove_file ⇒ Object
15 16 17 18 19 20 |
# File 'lib/bubbles/bubblicious_file.rb', line 15 def remove_file config.logger.debug("BubbliciousFile: removing file #{uid_file}") FileUtils.rm(uid_file) config.logger.debug("BubbliciousFile: removing file #{file}") FileUtils.rm(file) end |
#uid_file ⇒ Object
26 27 28 |
# File 'lib/bubbles/bubblicious_file.rb', line 26 def uid_file Pathname.new(processing_dir).join(uid_file_name) end |
#uid_file_name ⇒ Object
30 31 32 |
# File 'lib/bubbles/bubblicious_file.rb', line 30 def uid_file_name @uid_file_name ||= "#{uniq_filename_randomizer.call}#{file.extname}" end |