class MediaInformationGatherer::MediaType
Public Class Methods
new(options = {})
click to toggle source
@params [Hash] options Not currently used
# File lib/mig/modules/media_type.rb, line 6 def initialize(options = {}); end
Public Instance Methods
run(file_path, options = { })
click to toggle source
@params [String] file_path The path to the file to scan @params [Hash] options Not currently used @return [Hash] Will contain :type, :subtype and any other attributes output during the call
# File lib/mig/modules/media_type.rb, line 11 def run(file_path, options = { }) media_type, charset = (File.mime_type(file_path) || '').split(';') type, subtype = media_type.split('/') if media_type.is_a?(String) output = { :type => type, :subtype => subtype } param = charset.strip.split('=') if charset.is_a?(String) output[param.first] = param.last if param.is_a?(Array) output end