=begin Mimine, a lazy class for getting an approximed MIME type from a file. Mainly targets mail attachments REQUIREMENTS: * mime/types : http://rubyforge.org/projects/mime-types =end class Mimine attr_reader :mime def initialize( file_name, system_only = true ) @mime = nil unless system_only begin require 'mime/types' rescue system_only = true retry end @mime = MIME::Types.type_for( file_name ).last end @mime = `file -ib #{file_name}`.chomp.split(" ").last if @mime.nil? or ( @mime.respond_to? :empty? and @mime.empty? ) end def to_s @mime.to_s end def text? @mime =~ /text\/(.)*/ end end