media file: factor out file type detection code.
Factor out the file type detection code from MediaFile into a FileTypeDetector class so we can use it to detect archive files (.zip, .rar, .7z) too.
This commit is contained in:
@@ -155,7 +155,12 @@ module Danbooru
|
||||
false
|
||||
end
|
||||
|
||||
# @return [String] The archive format ("RAR", "ZIP", etc).
|
||||
# @return [Symbol] The archive format as detected by us (:zip, :rar, :7z, etc).
|
||||
def file_ext
|
||||
@file_ext ||= FileTypeDetector.new(file).file_ext
|
||||
end
|
||||
|
||||
# @return [String] The archive format as returned by libarchive ("RAR", "ZIP", etc).
|
||||
def format
|
||||
@format ||= entries.lazy.map(&:format).first
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user