Class: Bubbles::BubbliciousFile

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/bubbles/bubblicious_file.rb

Instance Method Summary collapse

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_dirObject



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

#metadataObject



22
23
24
# File 'lib/bubbles/bubblicious_file.rb', line 22

def 
  { original_name: file.basename.to_s }
end

#remove_fileObject



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_fileObject



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_nameObject



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