Class: Saviour::SourceFilenameExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/saviour/source_filename_extractor.rb

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ SourceFilenameExtractor

Returns a new instance of SourceFilenameExtractor.



3
4
5
# File 'lib/saviour/source_filename_extractor.rb', line 3

def initialize(source)
  @source = source
end

Instance Method Details

#detected_filenameObject



7
8
9
# File 'lib/saviour/source_filename_extractor.rb', line 7

def detected_filename
  original_filename || path_filename
end

#original_filenameObject



11
12
13
14
# File 'lib/saviour/source_filename_extractor.rb', line 11

def original_filename
  value = @source.original_filename if @source.respond_to?(:original_filename)
  value if !value.nil? && value != ''
end

#path_filenameObject



16
17
18
19
# File 'lib/saviour/source_filename_extractor.rb', line 16

def path_filename
  value = @source.path if @source.respond_to?(:path)
  ::File.basename(value) if !value.nil? && value != ''
end