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

#metadataObject



20
21
22
# File 'lib/bubbles/bubblicious_file.rb', line 20

def 
  { original_name: file.basename.to_s }
end

#move_to_processing_dirObject



10
11
12
13
# File 'lib/bubbles/bubblicious_file.rb', line 10

def move_to_processing_dir
  config.logger.debug("BubbliciousFile: moving file #{file} to #{uid_file}")
  FileUtils.mv(file, uid_file)
end

#remove_fileObject



15
16
17
18
# File 'lib/bubbles/bubblicious_file.rb', line 15

def remove_file
  config.logger.debug("BubbliciousFile: removing file #{uid_file}")
  FileUtils.rm(uid_file)
end

#uid_fileObject



24
25
26
# File 'lib/bubbles/bubblicious_file.rb', line 24

def uid_file
  Pathname.new(processing_dir).join(uid_file_name)
end

#uid_file_nameObject



28
29
30
# File 'lib/bubbles/bubblicious_file.rb', line 28

def uid_file_name
  @uid_file_name ||= "#{uniq_filename_randomizer.call}#{file.extname}"
end